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

TagsInput onChange firing twice on enter selection after search #6414

Closed
2 tasks done
Knamer95 opened this issue Jun 19, 2024 · 2 comments · Fixed by #6416
Closed
2 tasks done

TagsInput onChange firing twice on enter selection after search #6414

Knamer95 opened this issue Jun 19, 2024 · 2 comments · Fixed by #6416

Comments

@Knamer95
Copy link
Contributor

Knamer95 commented Jun 19, 2024

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.10.2

What package has an issue?

@mantine/core

What framework do you use?

Next.js

In which browsers you can reproduce the issue?

All

Describe the bug

When you select an option from the dropdown with the arrow keys + Enter key, it will cause the onChange to fire twice if there was a search on the input. This is probably caused by the Enter base action, which will submit the value even if it's not in the dropdown, plus the select option action.

If there is no search, it will only fire once. If the option is selected with the mouse, it will only fire once as well. In those cases it works as intended.

Steps to reproduce: In a list with the option "react", type "re" on the TagsInput, then navigate to the option with the arrow keys, and press Enter key. It will fire first for the value "re", and then for "react".

If possible, include a link to a codesandbox with a minimal reproduction

https://codesandbox.io/p/sandbox/determined-morse-2kyvpl

Possible fix

Prevent the Enter action to fire the first onChange if there is an option already selected in the dropdown.

I'm willing to implement a fix for this, if it's considered an issue.

Self-service

  • I would be willing to implement a fix for this issue
@rtivital
Copy link
Member

You are welcome to submit a PR with a fix

@Knamer95
Copy link
Contributor Author

I fixed it and updated it to the latest Mantine version (7.11.0).

As a sidenote, I noticed the prop selectFirstOptionOnChange on TagsInput doesn't seem to be used anywhere (besides props' destructuring), nor does anything. It's also in the docs' props tab, but I'm not sure if it's a mistake from copy pasting from other components like Select/MultiSelect, or it's missing the effect said components have but it's meant to have the functionality.

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

Successfully merging a pull request may close this issue.

2 participants