Skip to content

Commit 9b03e17

Browse files
committed
fix: temporarily add the click event to fix #29
1 parent 58b7a52 commit 9b03e17

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/components/ui/base/Select.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const Select = <T extends SelectOptionType>(inputProps: Props<T>) => {
2424
selectedOption: props.options.find(o => o.value === props.value),
2525
readOnly: props.readonly,
2626
onChange: (detail) => {
27+
console.log('trigger')
2728
if (detail) {
2829
setSelectedItem(props.options.find(o => o.value === detail.value))
2930
props.onChange(detail.value)
@@ -35,10 +36,8 @@ export const Select = <T extends SelectOptionType>(inputProps: Props<T>) => {
3536

3637
createEffect(on(() => props.value, () => {
3738
const option = props.options.find(o => o.value === props.value)
38-
if (option) {
39-
api().setSelectedOption(option)
39+
if (option)
4040
setSelectedItem(option)
41-
}
4241
}))
4342

4443
const selectedComponent = (item: T | null) => {
@@ -81,8 +80,14 @@ export const Select = <T extends SelectOptionType>(inputProps: Props<T>) => {
8180
<div class="w-$reference-width -mt-2 z-100 shadow-md" {...api().positionerProps}>
8281
<ul class="bg-base" {...api().contentProps}>
8382
{props.options.map(item => (
84-
<li {...api().getOptionProps({ label: item.label, value: item.value })}>
85-
{itemComponent(item, item.value === api().selectedOption?.value)}
83+
<li
84+
{...api().getOptionProps({ label: item.label, value: item.value })}
85+
onClick={() => {
86+
setSelectedItem(item)
87+
props.onChange(item.value)
88+
}}
89+
>
90+
{itemComponent(item, item.value === selectedItem()?.value)}
8691
</li>
8792
))}
8893
</ul>

0 commit comments

Comments
 (0)