@@ -79,6 +79,8 @@ export const Dropdown = ({
7979  /* istanbul ignore next */ 
8080  const  innerNode  =  useMemo ( ( )  =>  ( children  ? < span > { children } </ span >  : null ) ,  [ children ] ) 
8181
82+   const  [ searchTerm ,  setSearchTerm ]  =  useState ( '' ) 
83+ 
8284  const  [ selectedItems ,  setSelectedItems ]  =  useState < string [ ] > ( persistSelection  ? initialSelectedItems  : [ ] ) 
8385  const  updateSelectedItems  =  useCallback ( ( itemId : string )  =>  { 
8486    if  ( ! persistSelection )  { 
@@ -93,12 +95,13 @@ export const Dropdown = ({
9395      const  itemClickEvent : DropdownClickEvent  =  eventAdapter ( antdEvent ,  itemFinderMemo ) 
9496      updateSelectedItems ( itemClickEvent . id ) 
9597      onClick ( itemClickEvent ) 
98+       if  ( isSearchable  &&  searchTerm )  { 
99+         setSearchTerm ( '' ) 
100+       } 
96101    } , 
97-     [ itemFinderMemo ,  onClick ,  updateSelectedItems ] 
102+     [ isSearchable ,   itemFinderMemo ,  onClick ,   searchTerm ,  updateSelectedItems ] 
98103  ) 
99104
100-   const  [ searchTerm ,  setSearchTerm ]  =  useState ( '' ) 
101- 
102105  const  itemsToRender  =  useMemo ( ( )  =>  { 
103106    if  ( onSearch  ||  ! searchTerm )  { 
104107      return  items 
@@ -151,27 +154,29 @@ export const Dropdown = ({
151154
152155  const  headerComponent  =  useMemo ( 
153156    ( )  =>  ( 
154-       < div   style = { {   padding :  spacing . gap . sm ,   paddingBottom :  spacing . gap . xs   } } > 
157+       < > 
155158        { header ?. top } 
156159        { isSearchable  &&  ( 
157-           < BaseInput 
158-             allowClear 
159-             component = { AntInput } 
160-             isFullWidth 
161-             placeholder = { searchPlaceholder } 
162-             suffix = { 
163-               < Icon 
164-                 color = { palette . action . secondary . contrastText } 
165-                 component = { PiMagnifyingGlass } 
166-                 size = { ICON_SIZE } 
167-               /> 
168-             } 
169-             value = { searchTerm } 
170-             onChange = { handleSearchInputChange } 
171-           /> 
160+           < div  style = { {  padding : spacing . gap . sm ,  paddingBottom : spacing . gap . xs  } } > 
161+             < BaseInput 
162+               allowClear 
163+               component = { AntInput } 
164+               isFullWidth 
165+               placeholder = { searchPlaceholder } 
166+               suffix = { 
167+                 < Icon 
168+                   color = { palette . action . secondary . contrastText } 
169+                   component = { PiMagnifyingGlass } 
170+                   size = { ICON_SIZE } 
171+                 /> 
172+               } 
173+               value = { searchTerm } 
174+               onChange = { handleSearchInputChange } 
175+             /> 
176+           </ div > 
172177        ) } 
173178        { header ?. bottom } 
174-       </ div > 
179+       </ > 
175180    ) , 
176181    [ 
177182      handleSearchInputChange , 
@@ -264,17 +269,14 @@ export const Dropdown = ({
264269    ( open : boolean ,  info : {  source : 'trigger'  |  'menu'  } )  =>  { 
265270      if  ( ! open  &&  isSearchable  &&  searchTerm )  { 
266271        setSearchTerm ( '' ) 
267-         if  ( onSearch )  { 
268-           onSearch ( '' ) 
269-         } 
270272      } 
271273
272274      if  ( ! onOpenChange )  { 
273275        return 
274276      } 
275277      onOpenChange ( open ,  {  source : antdSourceMap [ info . source ]  } ) 
276278    } , 
277-     [ isSearchable ,  onOpenChange ,  onSearch ,   searchTerm ] 
279+     [ isSearchable ,  onOpenChange ,  searchTerm ] 
278280  ) 
279281
280282  return  ( 
0 commit comments