Refactor select component to streamline value handling
- Removed the `onValueChange` prop from the select component to simplify its interface. - Updated the alias filter select component to ensure the selected value defaults to "all" if not present in available aliases, enhancing user experience.
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!value) value = "all";
|
if (!value) value = "all";
|
||||||
if (value !== "all" && !availableAliases.includes(value)) value = "all";
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,8 @@
|
|||||||
let {
|
let {
|
||||||
open = $bindable(false),
|
open = $bindable(false),
|
||||||
value = $bindable(),
|
value = $bindable(),
|
||||||
onValueChange,
|
|
||||||
...restProps
|
...restProps
|
||||||
}: SelectPrimitive.RootProps & {
|
}: SelectPrimitive.RootProps = $props();
|
||||||
onValueChange?: (next: string | string[]) => void;
|
|
||||||
} = $props();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SelectPrimitive.Root
|
<SelectPrimitive.Root bind:open bind:value={value as never} {...restProps} />
|
||||||
bind:open
|
|
||||||
bind:value={value as never}
|
|
||||||
onValueChange={(next: unknown) => {
|
|
||||||
value = next as typeof value;
|
|
||||||
onValueChange?.(next as string | string[]);
|
|
||||||
}}
|
|
||||||
{...restProps}
|
|
||||||
/>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user