Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing in a PowerSelectMultiple's trigger (when search is disabled) triggers bad onChange #1522

Open
kevinkucharczyk opened this issue Jun 14, 2022 · 0 comments

Comments

@kevinkucharczyk
Copy link

Let's take the PowerSelectMultiple example from the docs, but remove @searchEnabled (this is important - when search is enabled, this bug doesn't happen because the trigger is then an input):

<PowerSelectMultiple
  @options={{this.names}}
  @selected={{this.name}}
  @placeholder="Select some names..."
  @onChange={{fn (mut this.name)}}
  as |name|
>
  {{name}}
</PowerSelectMultiple>

When we click the trigger to open the dropdown, then click it again to close and start typing with the keyboard, the Power Select component will call onChange with an option item, if the typed keyboard character matches a result. Here's a screencast of the process:
CleanShot 2022-06-14 at 13 26 14

The click-to-open then click-to-close is necessary, because it leaves the trigger in a focused state.

The problem is that, when we use PowerSelectMultiple, the expectation is that selected will be an array, and likewise onChange will be called with an array of items. However, in this situation, onChange is called with one single option item - in the docs example, that's a string.

This happens because:

I'm not sure, however, what the best fix is. Perhaps PowerSelectMultiple should discard the current selection and call onChange with an array of 1 item when this scenario happens. PowerSelects _select action would need updating, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant