Skip to content

Checkbox doesn't have it's checked state set via v-model if the click event is prevented #9535

@danielsamuels

Description

@danielsamuels

Version

2.6.6

Reproduction link

https://jsfiddle.net/s4ub8dnc/3/

Steps to reproduce

I have a checkbox which needs to get it's checked state from a VueX store, but I also need to be able to determine whether or not shift was being held when the checkbox was clicked. To do this I'm using @click.prevent on the checkbox (so that I have the event being passed to the method) and then using v-model to determine the checked state.

However, regardless of whether or not the v-model value is true or false, the checkbox never gains the checked state if the click is prevented. It seems that there is still a reliance on the click event in order to set the state.

What is expected?

I would expect the checkbox to be checked if the v-model value is set to true, regardless of how the checkbox arrived at that state - by something else setting it to true, or by the click handler setting it.

What is actually happening?

The click binding having .prevent on it stops the checkbox from receiving it's checked state, even when the v-model value is true


The reason why I haven't just used a setter in the computed is because the setter doesn't get given the click event, so I can determine whether or not shift was being held at the point of clicking the checkbox.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions