@@ -24,6 +24,7 @@ export const Select = <T extends SelectOptionType>(inputProps: Props<T>) => {
24
24
selectedOption : props . options . find ( o => o . value === props . value ) ,
25
25
readOnly : props . readonly ,
26
26
onChange : ( detail ) => {
27
+ console . log ( 'trigger' )
27
28
if ( detail ) {
28
29
setSelectedItem ( props . options . find ( o => o . value === detail . value ) )
29
30
props . onChange ( detail . value )
@@ -35,10 +36,8 @@ export const Select = <T extends SelectOptionType>(inputProps: Props<T>) => {
35
36
36
37
createEffect ( on ( ( ) => props . value , ( ) => {
37
38
const option = props . options . find ( o => o . value === props . value )
38
- if ( option ) {
39
- api ( ) . setSelectedOption ( option )
39
+ if ( option )
40
40
setSelectedItem ( option )
41
- }
42
41
} ) )
43
42
44
43
const selectedComponent = ( item : T | null ) => {
@@ -81,8 +80,14 @@ export const Select = <T extends SelectOptionType>(inputProps: Props<T>) => {
81
80
< div class = "w-$reference-width -mt-2 z-100 shadow-md" { ...api ( ) . positionerProps } >
82
81
< ul class = "bg-base" { ...api ( ) . contentProps } >
83
82
{ 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 ) }
86
91
</ li >
87
92
) ) }
88
93
</ ul >
0 commit comments