Allow to sort options in select selector (#97680)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Paul Bottein 2023-08-03 21:49:22 +02:00 committed by GitHub
parent d33955c467
commit 83af2f5b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -988,6 +988,7 @@ class SelectSelectorConfig(TypedDict, total=False):
custom_value: bool
mode: SelectSelectorMode
translation_key: str
sort: bool
@SELECTORS.register("select")
@ -1005,6 +1006,7 @@ class SelectSelector(Selector[SelectSelectorConfig]):
vol.Coerce(SelectSelectorMode), lambda val: val.value
),
vol.Optional("translation_key"): cv.string,
vol.Optional("sort", default=False): cv.boolean,
}
)

View File

@ -201,6 +201,7 @@ async def test_get_trigger_capabilities_node_status(
"mode": "dropdown",
"multiple": True,
"options": [],
"sort": False,
},
},
}

View File

@ -655,6 +655,11 @@ def test_text_selector_schema(schema, valid_selections, invalid_selections) -> N
(["red"], ["green", "blue"], []),
(0, None, "red"),
),
(
{"options": ["red", "green", "blue"], "sort": True},
("red", "blue"),
(0, None, ["red"]),
),
),
)
def test_select_selector_schema(schema, valid_selections, invalid_selections) -> None: