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

QInput returns empty string for number model #17359

Closed
ymarcon opened this issue Jul 9, 2024 · 2 comments
Closed

QInput returns empty string for number model #17359

ymarcon opened this issue Jul 9, 2024 · 2 comments
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@ymarcon
Copy link

ymarcon commented Jul 9, 2024

What happened?

When using the QInput to capture numbers, deleting the entry sets the model's value to an empty string, which is not a number as expected.

What did you expect to happen?

Deleting the number input entry manually or using the clearable icon should give the same result: a null value

Reproduction URL

https://codepen.io/yop12/pen/NWZWQdK

How to reproduce?

  1. use codepen link and open console
  2. enter a number and delete it manually (resp. using the clearable) and check the output in the console: the model's number value is an empty string (resp. a null value).

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Components (quasar)

Platforms/Browsers

No response

Quasar info output

No response

Relevant log output

No response

Additional context

No response

@ymarcon ymarcon added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Jul 9, 2024
@github-actions github-actions bot added area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite labels Jul 9, 2024
@yusufkandemir
Copy link
Member

yusufkandemir commented Jul 10, 2024

Hi, unfortunately, it's how Vue behaves. You will get the same behavior if you use a native <input> as well.
vuejs/vue#4742
vuejs/core#8214

It's a bit annoying, but you can workaround it by using something like :model-value="model" + @update:model-value="value => { model = value === '' || value === null || value === undefined ? null : parseFloat(value); }"

@yusufkandemir yusufkandemir closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
@ymarcon
Copy link
Author

ymarcon commented Jul 10, 2024

Oh ok I see... I have this kind of workaround already but I thought it could be integrated into the component. Anyways thx @yusufkandemir for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

2 participants