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

Option validation in ComboBox is too strict #7176

Closed
2 tasks done
ustun-ed opened this issue Nov 27, 2024 · 2 comments
Closed
2 tasks done

Option validation in ComboBox is too strict #7176

ustun-ed opened this issue Nov 27, 2024 · 2 comments
Labels
Works as intended The behavior described in the issue is intended and is not a bug

Comments

@ustun-ed
Copy link
Contributor

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?

Latest

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

If the Combobox has duplicate options, Mantine fails instead of showing a warning, unlike React.

This might result in unexpected failures if the data coming from the backend has duplicate data all of a sudden and the frontend code was not written defensively to make the incoming data unique.

For example, if the Combobox appears in a Modal, the Modal crashes and is not shown at all.

It would be hard to make sure every input to Combobox is unique in all cases, so I think the validation should be relaxed and applied on-demand.

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

No response

Possible fix

No response

Self-service

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

It is not planned to change this behavior. If options are not unique, Combobox component will not work correctly, all of its features are bound to option value, including keyboard navigation, option retrieving from the list and scrolling to a specific option. The function is implemented to throw an error to explicitly notify the developer that the data cannot be processed.

To fix the issue, transform the data on your side before passing it to the component.

@ustun-ed
Copy link
Contributor Author

@rtivital OK, I see. I still think it is a bit too punishing as users might not be aware of this restriction.

In any case, I opened this PR that at least provides some warning in the docs about the uniqueness requirement: #7181

There might be a better place to communicate this in the docs as most may not look at the props tab of these components. Maybe we put that in the first paragraph of each component?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Works as intended The behavior described in the issue is intended and is not a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants