Vuetify: [Bug Report] v-radio retrieves wrong value for null

Created on 6 Sep 2019  路  4Comments  路  Source: vuetifyjs/vuetify

Environment

Vuetify Version: 2.0.15
Last working version: 1.5.17
Vue Version: 2.6.10
Browsers: Chrome 76.0.3809.87
OS: Linux x86_64

Steps to reproduce

Do not set prop value for a <v-radio> component, or set it to null:

<v-radio-group v-model="radio">
  <v-radio :value="null"></v-radio>
  <v-radio></v-radio>
</v-radio-group>

Expected Behavior

Setting no :value for a <v-radio> tag should return null for this element.

Codepen with 1.5 version working has expected

Actual Behavior

radio should be null when one of those radios are selected, but instead it takes the index of the element as value.

Reproduction Link

https://codepen.io/Blancowicz/pen/xxKpzyQ

triage wontfix

Most helpful comment

Actually this method doesn't exist on VRadio, it exists on the VRadioGroup. So a complete alternative would be:

import { VRadioGroup } from 'vuetify/lib'

export default {
  extends: VRadioGroup,

  methods: {
    getValue (item) {
      return item.value
    }
  }
}

There seems to be a lot of checks for null though internally for this Vuetify component (or rather VItemGroup which VRadioGroup extends), so although this seems to work in our project YMMV.

All 4 comments

Looks like this is intented behavior:
image

Thanks for taking your time to watch this @sh7dm

You can change this behavior in your project by extending if you want:

import { VRadio } from 'vuetify/lib'

export default {
  extends: VRadio,

  methods: {
    getValue (item, i) {
      ...
    }
  }
}

Actually this method doesn't exist on VRadio, it exists on the VRadioGroup. So a complete alternative would be:

import { VRadioGroup } from 'vuetify/lib'

export default {
  extends: VRadioGroup,

  methods: {
    getValue (item) {
      return item.value
    }
  }
}

There seems to be a lot of checks for null though internally for this Vuetify component (or rather VItemGroup which VRadioGroup extends), so although this seems to work in our project YMMV.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smousa picture smousa  路  3Comments

paladin2005 picture paladin2005  路  3Comments

cawa-93 picture cawa-93  路  3Comments

itanka9 picture itanka9  路  3Comments

KuroThing picture KuroThing  路  3Comments