@@ -194,6 +194,10 @@ type PickerProps<T extends object> = {
194194 * as a text element with appropriate styling. If a React node is provided, it will be rendered as is.
195195 */
196196 noMatchesFallback ?: React . ReactNode ;
197+ /**
198+ * Whether the picker should be searchable. If true, renders a search input.
199+ */
200+ searchable ?: boolean ;
197201} ;
198202
199203type PickerContextState < T extends object > = {
@@ -478,6 +482,7 @@ export const Picker = typedMemo(<T extends object>(props: PickerProps<T>) => {
478482 noOptionsFallback,
479483 OptionComponent = DefaultOptionComponent ,
480484 NextToSearchBar,
485+ searchable,
481486 } = props ;
482487 const [ $activeOptionId ] = useState ( ( ) => {
483488 const initialValue = getFirstOptionId ( rawOptions , getOptionId ) ;
@@ -546,7 +551,7 @@ export const Picker = typedMemo(<T extends object>(props: PickerProps<T>) => {
546551 ) ;
547552
548553 useEffect ( ( ) => {
549- if ( ! debouncedSearchTerm ) {
554+ if ( ! debouncedSearchTerm || ! searchable ) {
550555 $filteredOptions . set ( options ) ;
551556 $activeOptionId . set ( getFirstOptionId ( options , getOptionId ) ) ;
552557 } else {
@@ -567,7 +572,16 @@ export const Picker = typedMemo(<T extends object>(props: PickerProps<T>) => {
567572 $filteredOptions . set ( filtered as T [ ] | Group < T > [ ] ) ;
568573 $activeOptionId . set ( getFirstOptionId ( filtered as T [ ] | Group < T > [ ] , getOptionId ) ) ;
569574 }
570- } , [ debouncedSearchTerm , $activeOptionId , props . options , options , getOptionId , isMatch , $filteredOptions ] ) ;
575+ } , [
576+ debouncedSearchTerm ,
577+ $activeOptionId ,
578+ props . options ,
579+ options ,
580+ getOptionId ,
581+ isMatch ,
582+ $filteredOptions ,
583+ searchable ,
584+ ] ) ;
571585
572586 const onSelectById = useCallback (
573587 ( id : string ) => {
@@ -641,7 +655,7 @@ export const Picker = typedMemo(<T extends object>(props: PickerProps<T>) => {
641655 return (
642656 < PickerContext . Provider value = { ctx } >
643657 < PickerContainer >
644- < PickerSearchBar value = { searchTerm } onChange = { onChangeSearchTerm } isDisabled = { ! hasOptions } />
658+ { searchable && < PickerSearchBar value = { searchTerm } onChange = { onChangeSearchTerm } isDisabled = { ! hasOptions } /> }
645659 < Flex tabIndex = { - 1 } w = "full" flexGrow = { 1 } >
646660 { ! hasOptions && < NoOptionsFallback /> }
647661 { hasOptions && ! hasFilteredOptions && < NoMatchesFallback /> }
0 commit comments