Vuetify: [Documentation] prefer @change over @click on selection controls

Created on 29 Jan 2020  路  7Comments  路  Source: vuetifyjs/vuetify

Environment

Vuetify Version: 2.2.6 and 2.2.8
Vue Version: 2.6.10
Browsers: Firefox 72.0
OS: Linux

Steps to reproduce

  • Add Checkbox element
  • Listen to click event

Expected Behavior

Click is triggered once after click

Actual Behavior

Click is triggered twice after click

Reproduction Link

Vuetify 2.2.6: https://codepen.io/peteruithoven/pen/OJPYmbm
Vuetify 2.2.8: https://codepen.io/peteruithoven/pen/XWJwRqL

Other comments

One workaround seems to be to stop the click event's propagation by adding .stop.

VCheckbox VRadio VSwitch documentation

Most helpful comment

@KaelWD you are right. Using only @change works perfectly. I've updated my example.

All 7 comments

I can also reproduce this with Vuetify 2.2.8:
https://codepen.io/peteruithoven/pen/XWJwRqL

You should be using input-value and @change here anyway (or v-model).

@KaelWD but @change isn't listed in the API:
https://vuetifyjs.com/en/components/selection-controls#api

I tried adding it in the same codepen, but it doesn't seem to be triggered:
https://codepen.io/peteruithoven/pen/XWJwRqL

(I can't easily use v-model for my use case)

The bound click event is overwriting the internal one so it breaks change, if you remove @click it works correctly.

Related: #5968

@KaelWD you are right. Using only @change works perfectly. I've updated my example.

Yeah, docs DEFINITELY need to note in bold that @click will trigger twice. This can cause some pretty unpleasant effects...

5968 has been fixed, docs need to note that you almost always want to be using @change instead of @click

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitar picture mitar  路  38Comments

Christilut picture Christilut  路  41Comments

wernerm picture wernerm  路  42Comments

noorzaie picture noorzaie  路  38Comments

johnleider picture johnleider  路  93Comments