digdir / designsystemet

Designsystemet
https://designsystemet.no
MIT License
82 stars 38 forks source link

Combobox - selecting a filtered value resets the input #1595

Open hansenalexander opened 8 months ago

hansenalexander commented 8 months ago

Description of the bug

When filtering options in a combobox and selecting a value I'd expect it not to remove the searchstring as it does now. If the list is long and I want to select all the values that starts with a specific pattern I would have to filter again and again. In addition to this you won't be sent back to the top of the list, you'll notice this in a longer list of options.

Steps To Reproduce

  1. Go to https://storybook.designsystemet.no/?path=/docs/felles-combobox--docs
  2. Find the multiple-example
  3. Type 'T' and you should get two matches
  4. Choose 1 of the values
  5. At this point the inputfield has been reset and if you wanted to choose both values starting with 'T' you would either have to filter again or find it manually by scrolling.

Additional Information

No response

mimarz commented 8 months ago

Thanks for the feedback, I can see how this is useful for some use-cases and types of data :)

We'll need to have a closer look at how this impacts accessibility and what would be the best way to solve something like this.

Some thoughts:

Barsnes commented 7 months ago

Thanks for the feedback, I can see how this is useful for some use-cases and types of data :)

We'll need to have a closer look at how this impacts accessibility and what would be the best way to solve something like this.

Some thoughts:

  • This makes more sense for multiple than single selection behaviours
  • Accessibility issues? How would this affect screen-readers?
  • Should this be default behaviour or toggle-able?

I suggest we make this a prop, resetInputOnSelect, that is by default true - This way we keep the behaviour we have today, but users still get the option to turn this off.