You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on how the SelectNext component was architected, one way to support filtering items would be introducing a new <Select.Filterable /> wrapper for <Select.Option /> items, which allows children to be filtered via context.
Then we can expose the onFilter callback via context, down to the Option entries, which can decide if they should render or not, based on that.
We could even allow multiple Filterable blocks, or options outside any Filterable, that cannot be filtered. Ideally the search box should be position sticky, making sure it's visible while scrolling between the options it can filter.
The Filterable component could be something in these lines:
constFilterableContext=createContext<{shouldRender: (value: T)=>boolean}|null>(null);functionFilterable<T>({ onFilter, placeholder, children }){const[query,setQuery]=useState('');constshouldRender=useCallback((value: T)=>onFilter(query,value),[onFilter,query],);return(<FilterableContext.Providervalue={{ shouldRender }}><inputtype="search"placeholder={placeholder}value={query}onInput={e=>setQuery(e.target.value)}/>{children}</FilterableContext.Provider>);}
The text was updated successfully, but these errors were encountered:
Add some way to do text search inside the
SelectNext
options, as sketched here hypothesis/client#5775 (comment)Based on how the
SelectNext
component was architected, one way to support filtering items would be introducing a new<Select.Filterable />
wrapper for<Select.Option />
items, which allows children to be filtered via context.Then we can expose the
onFilter
callback via context, down to theOption
entries, which can decide if they should render or not, based on that.We could even allow multiple Filterable blocks, or options outside any Filterable, that cannot be filtered. Ideally the search box should be position sticky, making sure it's visible while scrolling between the options it can filter.
The
Filterable
component could be something in these lines:The text was updated successfully, but these errors were encountered: