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

[Bug Report][3.7.5] v-autocomplete sets selected value to null when emptied #20761

Open
jtuchel opened this issue Dec 5, 2024 · 2 comments
Open

Comments

@jtuchel
Copy link

jtuchel commented Dec 5, 2024

Environment

Vuetify Version: 3.7.5
Vue Version: 3.5.13
Browsers: Firefox 132.0
OS: Linux x86_64

Steps to reproduce

In the playground try to empty the autocomplete by pressing backspace.

You should see that the value of currentPage turns into null.

Expected Behavior

I would expect the autocomplete to delay the model change until the user selects a valid value.

Actual Behavior

The autocomplete sets the value to null when emptied.

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

One can write their own workaround by inspecting the value in the change event. If it's null, use the first page ( or whatever you like ) as a fallback.

Workaround:
https://play.vuetifyjs.com/#eNptUtFK7DAQ/ZUhT13uukUulwtruyg+6YMKgi9WJHanayCdhHSyKqX/btK0uyv4UpqcM3POnMlzLzpX51fWrvYexVoUXe2UZeiQvQUtaVdWgrtKbCoCUK01jqEHh80SatNaz7iFARpnWqhE6FGJi4oitzbUMdTeOSR+kDuEMpZlfxeBMMOyNZ74vol4NxH+/Y+MI8cG7IaxjfgsmWULKDfQRxaEKvaO4Mo5+bWKVrIeNNKO39c/FVZ7qT3CsITsdQmKtvg59hn/4A+cJ2/DbKDxVLMyBIau30MWmBF+xE6LWVo18xWUZQnktT5gYYDj9JN0CeejxNH2dByS4u81k0QyV1GRpy2FnYRDiMZqyThuqNifhdRYKkK3uU6txgRBdWvoe7h9vL9bdewU7VTzlZ2oLWAYivy0fmooPZsYvEbG5FHLN9ThYcSySqS7tYo7CpeHfR2Q1mxRn43DBPxEcmZcersNEyTi08SbM0+kPLgp8pNZxbCMaY+fl28pnu/T

But this is not the ideal solution because now the application would try to load the data for page 1 but the user might want to modify the input before doing so.

⚠️ My app is using the pagination component but a few customers have a lot of pages and a quick jump would be nice so I'm also offering this option. If the pagination component offers something by default, please let me know ⚠️

@J-Sek
Copy link
Contributor

J-Sek commented Dec 5, 2024

In general receiving null once the field is empty is a valid selection. You seem to have a niche use case when selection is required and you somehow have so many pages that VSelect is not good enough as users need better experience when searching for page with keyboard... It looks more like a feature request for some sort of :default-value='1' or mandatory='force'.

@J-Sek
Copy link
Contributor

J-Sek commented Dec 5, 2024

I can offer 2 workarounds. One is just a wrapper on VAutocomplete preventing null from being emitted The second is more complex. You may ignore the warnings about duplicate IDs, as they would be hopefully fixed in 3.8.x.

An alternative would be to have pure VSelect, but reduce amount of options to every hundred (i.e. 100, 200, 300, etc) assuming people browse/explore these pages and don't need the specific one 142nd that they remember from yesterday or something..

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