zendeskgarden/react-components

Multiselect: Add-new item causes `onSelect` handler to fire twice

Anifacted opened this issue · 2 comments

In the Multiselect component, when having the option of adding a new item to the list (via the AddItem component), hitting ENTER to confirm the action causes the onSelect handler to be called twice.
Note: It does not happen when simply clicking the AddItem. In this case, the handler is fired once as expected.

Expectations

I expect that hitting ENTER with the AddItem highlighted invokes the onSelect handler once.

Screenshot 2023-02-20 at 14 03 48

Reality

Hitting ENTER with the AddItem highlighted invokes the onSelect handler twice.

Screenshot 2023-02-20 at 14 03 28

Steps to Reproduce

  1. Go to codesandbox: https://codesandbox.io/s/intelligent-booth-veebni?file=/src/Example.tsx
  2. Open the console
  3. Click the Multiselect component, enter a search and hit ENTER over the "Add new"-item
  4. Observe how the items are logged twice (i.e. the onSelect handler was invoked twice).

Fine Print

  • Component: Multiselect
  • Version: v8.48.0 (and forward)
  • Browsers: all

Notes

I observed this bug to have been introduced in v8.48.0 of react-dropdowns, since v8.47.0 does not have the issue.
Here's a comparison between the two: v8.47.0...v8.48.0

I am led to suspect that this commit could be responsible given its description: 1664050

Hey @Anifacted thank you for the comprehensive report! This is a known issue we have been tracking and will hopefully get to it in the coming future. Thanks for being patient with us.