react-datalist-input icon indicating copy to clipboard operation
react-datalist-input copied to clipboard

Expose hook with current input to user

Open andrelandgraf opened this issue 1 year ago • 0 comments

Problem

I don't think there is currently a way for a user to access the current input value of the input field. The input value would be useful in case one wants to use a custom item component that highlights the matching part of the label string.

Background

You can pass a custom component for each item in the items array as a node property. The node property will then be rendered for each item. In that case, you currently do not have access to the current input to do some custom highlighting.

Custom highlighting would require that the module exposes a hook that has access to ComboboxContext. ComboboxContext should be extended to also include the current input value. The value can then be exposed via the hook and accessed in the custom item component.

Task

Add current input value to ComboboxContext and expose ComboboxContext values through hook to use in custom item component.

  1. Investigate if there is currently a way to access the input value
  2. Pass current input value to ComboboxContext
  3. Create hook that is exposed to user that returns value (and maybe other useful data)
  4. Document use case in README

andrelandgraf avatar Oct 22 '22 05:10 andrelandgraf