mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Allow to sort options in select selector (#97680)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
d33955c467
commit
83af2f5b8b
@ -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,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -201,6 +201,7 @@ async def test_get_trigger_capabilities_node_status(
|
||||
"mode": "dropdown",
|
||||
"multiple": True,
|
||||
"options": [],
|
||||
"sort": False,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user