11import * as React from 'react' ;
2- import clsx from 'clsx' ;
32import Affix from './Affix' ;
43import SelectContent from './Content' ;
54import SelectInputContext from './context' ;
@@ -94,7 +93,7 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
9493 ...restProps
9594 } = props ;
9695
97- const { triggerOpen, toggleOpen } = useBaseProps ( ) ;
96+ const { triggerOpen, toggleOpen, showSearch , disabled } = useBaseProps ( ) ;
9897
9998 const rootRef = React . useRef < HTMLDivElement > ( null ) ;
10099 const inputRef = React . useRef < HTMLInputElement > ( null ) ;
@@ -151,14 +150,23 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
151150
152151 // ====================== Open ======================
153152 const onInternalMouseDown : SelectInputProps [ 'onMouseDown' ] = useEvent ( ( event ) => {
154- event . preventDefault ( ) ;
155-
156- if ( ! ( event . nativeEvent as any ) . _select_lazy ) {
157- inputRef . current ?. focus ( ) ;
158- toggleOpen ( ) ;
159- } else if ( triggerOpen ) {
160- // Lazy should also close when click clear icon
161- toggleOpen ( false ) ;
153+ if ( ! disabled ) {
154+ event . preventDefault ( ) ;
155+
156+ // Check if we should prevent closing when clicking on selector
157+ // Don't close if: open && not multiple && (combobox mode || showSearch)
158+ const shouldPreventClose = triggerOpen && ! multiple && ( mode === 'combobox' || showSearch ) ;
159+
160+ if ( ! ( event . nativeEvent as any ) . _select_lazy ) {
161+ inputRef . current ?. focus ( ) ;
162+ // Only toggle open if we should not prevent close
163+ if ( ! shouldPreventClose ) {
164+ toggleOpen ( ) ;
165+ }
166+ } else if ( triggerOpen ) {
167+ // Lazy should also close when click clear icon
168+ toggleOpen ( false ) ;
169+ }
162170 }
163171
164172 onMouseDown ?.( event ) ;
@@ -184,7 +192,7 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
184192 { ...domProps }
185193 // Style
186194 ref = { rootRef }
187- className = { clsx ( className ) }
195+ className = { className }
188196 style = { style }
189197 // Open
190198 onMouseDown = { onInternalMouseDown }
0 commit comments