File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
packages/ui/src/dropdowns Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,13 @@ function Option(props: ICustomSelectItemProps) {
146146 const { children, value, className } = props ;
147147 const closeDropdown = useContext ( DropdownContext ) ;
148148
149- const handleMouseDown = useCallback ( ( ) => {
149+ const handleClick = useCallback ( ( ) => {
150150 // Close dropdown for both new and already-selected options.
151- requestAnimationFrame ( ( ) => closeDropdown ( ) ) ;
151+ // Use setTimeout to ensure HeadlessUI's onChange handler fires first for new selections.
152+ // For already-selected options, this ensures the dropdown closes since onChange won't fire.
153+ setTimeout ( ( ) => {
154+ closeDropdown ( ) ;
155+ } , 0 ) ;
152156 } , [ closeDropdown ] ) ;
153157
154158 return (
@@ -163,9 +167,10 @@ function Option(props: ICustomSelectItemProps) {
163167 className
164168 )
165169 }
170+ onClick = { handleClick }
166171 >
167172 { ( { selected } ) => (
168- < div onMouseDown = { handleMouseDown } className = "flex items-center justify-between gap-2 w-full" >
173+ < div className = "flex items-center justify-between gap-2 w-full" >
169174 { children }
170175 { selected && < Check className = "h-3.5 w-3.5 flex-shrink-0" /> }
171176 </ div >
You can’t perform that action at this time.
0 commit comments