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(() => {
|
||||
if (!value) value = "all";
|
||||
if (value !== "all" && !availableAliases.includes(value)) value = "all";
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -4,19 +4,8 @@
|
||||
let {
|
||||
open = $bindable(false),
|
||||
value = $bindable(),
|
||||
onValueChange,
|
||||
...restProps
|
||||
}: SelectPrimitive.RootProps & {
|
||||
onValueChange?: (next: string | string[]) => void;
|
||||
} = $props();
|
||||
}: SelectPrimitive.RootProps = $props();
|
||||
</script>
|
||||
|
||||
<SelectPrimitive.Root
|
||||
bind:open
|
||||
bind:value={value as never}
|
||||
onValueChange={(next: unknown) => {
|
||||
value = next as typeof value;
|
||||
onValueChange?.(next as string | string[]);
|
||||
}}
|
||||
{...restProps}
|
||||
/>
|
||||
<SelectPrimitive.Root bind:open bind:value={value as never} {...restProps} />
|
||||
|
||||
Reference in New Issue
Block a user