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

Using controlled value and searchValue in Select component makes it impossible to delete text input when item is selected #6245

Open
1 of 2 tasks
mark-pfeifle opened this issue May 16, 2024 · 0 comments · May be fixed by #6272

Comments

@mark-pfeifle
Copy link

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.9.1

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 using a searchable Select component with both controlled value and searchValue, it is impossible to delete the content of the text input as soon as a value has been selected. Steps to reproduce in the attached sandbox:

  • Choose item "One" from the select component
  • Click into input and try to delete the last letter of One by pressing backspace
  • Observed behavior: "One" will re-appear immediately afterwards so it's impossible to search for any other value

This seems to be related to a React re-render upon calling the function in "onSearchChange" which seems to overwrite the searchValue with the currently selected value. The problem also appears when only the value is controlled, not the search value but one still changes some state via the "onSearchChange"

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

https://codesandbox.io/p/sandbox/mantine-v7-searchable-select-9jmwvn?file=%2Fsrc%2FApp.jsx%3A44%2C21&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clw8xegty00063j6gu8u0hf4e%2522%252C%2522sizes%2522%253A%255B100%252C0%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clw8xegtx00023j6gthrbur3p%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clw8xegty00033j6gfrlbx400%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clw8xegty00053j6gbm78n17l%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B60.962440731822355%252C39.037559268177645%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clw8xegtx00023j6gthrbur3p%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clw8xegtx00013j6g6za41z8a%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clw8z8oz700433j6gyuc2i9fc%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A44%252C%2522startColumn%2522%253A21%252C%2522endLineNumber%2522%253A44%252C%2522endColumn%2522%253A21%257D%255D%252C%2522filepath%2522%253A%2522%252Fsrc%252FApp.jsx%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clw8xegtx00023j6gthrbur3p%2522%252C%2522activeTabId%2522%253A%2522clw8z8oz700433j6gyuc2i9fc%2522%257D%252C%2522clw8xegty00053j6gbm78n17l%2522%253A%257B%2522id%2522%253A%2522clw8xegty00053j6gbm78n17l%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clw8xegty00043j6g3uigbjfg%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clw8xegty00043j6g3uigbjfg%2522%257D%252C%2522clw8xegty00033j6gfrlbx400%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522clw8xegty00033j6gfrlbx400%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Afalse%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Possible fix

  • Modify re-rendering logic?

Self-service

  • I would be willing to implement a fix for this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant