@@ -2,7 +2,7 @@ import * as React from 'react';
22import clsx from 'clsx' ;
33import Affix from './Affix' ;
44import SelectContent from './Content' ;
5- import SelectInputContext , { type ContentContextProps } from './context' ;
5+ import SelectInputContext from './context' ;
66import type { DisplayValueType , Mode } from '../interface' ;
77
88export interface SelectInputRef {
@@ -95,6 +95,18 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
9595 const rootRef = React . useRef < HTMLDivElement > ( null ) ;
9696 const inputRef = React . useRef < HTMLInputElement > ( null ) ;
9797
98+ // Wrap onSearch to trigger dropdown open when typing
99+ const onInternalSearch = useEvent (
100+ ( searchText : string , fromTyping : boolean , isCompositing : boolean ) => {
101+ // Open dropdown when user is typing and not compositing
102+ if ( fromTyping && ! isCompositing && ! triggerOpen ) {
103+ toggleOpen ( true ) ;
104+ }
105+
106+ onSearch ?.( searchText , fromTyping , isCompositing ) ;
107+ } ,
108+ ) ;
109+
98110 // ====================== Refs ======================
99111 React . useImperativeHandle (
100112 ref ,
@@ -134,8 +146,14 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
134146 // ===================== Render =====================
135147 const domProps = omit ( restProps , DEFAULT_OMIT_PROPS ) ;
136148
149+ // Create context value with wrapped onSearch
150+ const contextValue = {
151+ ...props ,
152+ onSearch : onInternalSearch ,
153+ } ;
154+
137155 return (
138- < SelectInputContext . Provider value = { props } >
156+ < SelectInputContext . Provider value = { contextValue } >
139157 < div
140158 { ...domProps }
141159 // Style
0 commit comments