-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
fix(inputs): reset value to null instead of undefined #12373
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, this is a great PR that tremendously streamlines handling inputs' data!
I thought to highlight, however, that some traces of undefined
are still left unaltered. I can't tell whether they'd matter at all, but thought it'd better to point them out:
default: undefined, get (): string | undefined { this.lazySearch = undefined this.setValue(this.multiple ? [] : undefined) vuetify/packages/vuetify/src/components/VFileInput/VFileInput.ts
Lines 69 to 70 in 4a1bf59
value: { default: undefined, vuetify/packages/vuetify/src/components/VSelect/VSelect.ts
Lines 122 to 124 in 4a1bf59
lazyValue: this.value !== undefined ? this.value : this.multiple ? [] : undefined,
Hope it helps, and thank you.
Good catch, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's outside of this issue's scope but I think we should explore exposing the reset process so the user could set it to whatever they want.
Letting user a way to control the reset value - is a great idea! Hope someone could come up with an appropriate PR. |
Description
This fixes some inconsistencies when resetting input fields.
null
when clear was clicked, butundefined
in a form.undefined
or[]
if multiple.search-input
tonull
, unless clear was clicked then it would beundefined
insteadWith this change these will all be
null
or[]
, allowing values to be sent as JSON without having to check forundefined
first.This is technically a breaking change if someone was relying on
form.reset()
to reset inputs toundefined
but this is unlikely and can easily be worked around by setting the values manually afterwards.v-select also now re-selects an item with
value: null
if the clear button is clicked (#4431, unit test). Again, unlikely to actually be a problem (either intended behaviour or not using both clearable and a null item) and easily worked around by implementing the clear button yourself withappend-icon
and@click:clear
.The consistency is worth these low-impact changes in my opinion.
Some sort of clear-value prop (#4144, #7441) would be even better, but the PR was abandoned and apparently had problems with non-falsy values.
fixes #7429
Types of changes
Untested outside of existing unit tests btw, might be scuffed