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] Cannot have a radio box corresponding to a null value #9073

Closed
naffarn opened this issue Sep 23, 2019 · 3 comments · Fixed by #14436
Closed

[Bug Report] Cannot have a radio box corresponding to a null value #9073

naffarn opened this issue Sep 23, 2019 · 3 comments · Fixed by #14436
Assignees
Labels
C: VRadio VRadio T: bug Functionality that does not work as intended/expected
Milestone

Comments

@naffarn
Copy link

naffarn commented Sep 23, 2019

Environment

Vuetify Version: 2.0.18
Vue Version: 2.6.10
Browsers: Chrome 76.0.3809.132
OS: Linux x86_64

Steps to reproduce

Create a <v-radio-group /> with one <v-radio :value="null" />. That v-radio's value will actually correspond to its index in the group instead of the null :value passed to it.
The following snippet produces values true, false, and 2 in the bound model when selected in order:

<v-radio-group v-model="selected">
    <v-radio label="Yes" :value="true"></v-radio> <!-- selected === true -->
    <v-radio label="No" :value="false"></v-radio> <!-- selected === false -->
    <v-radio label="N/A" :value="null"></v-radio> <!-- selected === 2 -->
</v-radio-group>

Expected Behavior

The value assigned to the radio group model should equal the value assigned to the selected box at all times, in this case, null.

Actual Behavior

The value of the bound model is equal to the null radio's index, rather than the value prop passed in.

Reproduction Link

https://codepen.io/naffarn/pen/eYObxgE

Other comments

This is not an issue for checkboxes and switches that share a v-model for an array.

@ghost ghost added the S: triage label Sep 23, 2019
@johnleider johnleider added the C: VRadio VRadio label Oct 24, 2019
@johnleider johnleider self-assigned this Oct 24, 2019
@naffarn
Copy link
Author

naffarn commented Nov 26, 2019

Came up against this again in my development, worth noting that this applies to other non-numeric falsy values (e.g empty string) as well.

@Teellcory
Copy link

Whenever I need a null, I've been having to intercept before submit and change the 2 to null. It's an annoying extra step to have to do.

@Leespiker Leespiker added T: bug Functionality that does not work as intended/expected and removed S: triage labels Apr 5, 2020
@tihomir-kit
Copy link

Related: #8876

@KaelWD KaelWD assigned KaelWD and unassigned johnleider Nov 25, 2021
@KaelWD KaelWD added this to the v2.6.x milestone Nov 25, 2021
KaelWD added a commit that referenced this issue Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VRadio VRadio T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants