facuesr / react-multiselect-listbox

Multiple selection list box component
https://codesandbox.io/s/multi-select-listbox-example-lgvdf
0 stars 2 forks source link

add onSearch callback #18

Closed dzzzchhh closed 3 years ago

dzzzchhh commented 3 years ago

As requested by #2 and my current needs, I'd like to suggest an extension to component's API by adding ability to customise the searching capabilities.

Usage example:

      <MultiSelectListBox
        options={composeOptionsFromSource()}
        onSearch={({ items, textField, query }) =>
          items.filter((item) =>
            item[textField].toLowerCase().includes(query.toLowerCase())
          )
        }
        textField="text"
        valueField="value"
        value={values[name]}
        rowHeight={25}
        onSelect={handleListUpdate}
        onRemove={handleRemove}
        sortable={true}
        onSort={handleListUpdate}
      />
facuesr commented 3 years ago

Hi @dzzzchhh. Thanks. I uploaded the changes.

dzzzchhh commented 3 years ago

Awesome, thank you, @facuesr