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

MultiSelect2: createNewItemFromQuery is called redundantly #5992

Open
Last-Order opened this issue Mar 2, 2023 · 0 comments
Open

MultiSelect2: createNewItemFromQuery is called redundantly #5992

Last-Order opened this issue Mar 2, 2023 · 0 comments

Comments

@Last-Order
Copy link

As the documentation says, createNewItemFromQuery "invoked when user interaction causes one or many items to be created, either by pressing the Enter key or by clicking on the "Create Item" option". But in fact, the function is called once the MultiSelect2 component is initialized. Related code here:

const createNewItem = props.createNewItemFromQuery?.(query);

Environment

  • Package version(s): 4.9.3
  • Operating System: Windows 11
  • Browser name and version: Latest Chrome

Code Sandbox

Link to a minimal repro: https://codesandbox.io/s/nifty-hawking-oucqgc

Steps to reproduce

  1. Open console panel
  2. "createNewItemFromQuery is called!" is printed without any interactions.

Actual behavior

createNewItemFromQuery is called without user interactions.

Expected behavior

createNewItemFromQuery should be only invoked when user interaction causes one or many items to be created, either by pressing the Enter key or by clicking on the "Create Item" option.

Possible solution

Make the initial value of state.createNewItem to undefined?

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

No branches or pull requests

2 participants