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

ComboBox onOpen callback is called on each render #7022

Open
1 of 2 tasks
ndelon opened this issue Oct 24, 2024 · 1 comment
Open
1 of 2 tasks

ComboBox onOpen callback is called on each render #7022

ndelon opened this issue Oct 24, 2024 · 1 comment

Comments

@ndelon
Copy link

ndelon commented Oct 24, 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.13.4

What package has an issue?

@mantine/core

What framework do you use?

Vite

In which browsers you can reproduce the issue?

All

Describe the bug

Hello,

After upgrading my project to Mantine 7.13.4 (from 7.12.2), I observed that when using ComboBox, the onOpen function is now called each time the <Combobox.Options></Combobox.Options> is modified through onOptionSubmit.

I made a reproduction case here: https://codesandbox.io/p/sandbox/mantine-react-template-forked-763gq7 based on the Mantine Combobox documentation (https://mantine.dev/core/combobox/#usage).
Using Mantine 7.13.4, we can see that the onOpen function is called on each component render which leads to an infinite loop when the Combobox remains opened. If the dependencies are downgraded to 7.13.3, then the "open counter" is only incremented when the Combobox opens, as expected.

Maybe it is related to #7000.

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

https://codesandbox.io/p/sandbox/mantine-react-template-forked-763gq7

Possible fix

No response

Self-service

  • I would be willing to implement a fix for this issue
@ndelon
Copy link
Author

ndelon commented Oct 24, 2024

I wonder if it does come from this modification: 716194c#diff-0e3af7a38801d991836a26d7d003ab8b0db7628c36f37b77af245b82ad96974cR159 performed on 7.13.4.

If the onOpen call depends on the onOpen value, then if an onOpen arrow function triggers a re-render of the Combobox (to do a Combobox's store focusSearchInput() for instance) I think that the arrow function evaluates as a new value and triggers a new call to onOpen (in a infinite loop way).

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