Skip to content

Updating refs that are on <template> with @click on a checkbox input will not check the checkbox. #8638

Open
@dsaisho

Description

@dsaisho

Vue version

3.2

Link to minimal reproduction

https://play.vuejs.org/#eNp9kktPAjEUhf9K040QcDBhR4D4CAtNfETdWRdjuWCh0zZ9jJjJ/HdvW2dwYdhM2nNOc78zbUOvjCnqAHRG545bYTxx4INZMiUqo60nDbGwIS3ZWF2RM4yeMcUU18p5IpQJ/l6vQZJFjA3e3oedx6X7FS9QO6qC72GNzsCBBO6FVsPFsmGKxBNFXcoAo1E80MbPfJKpkAc3HiojSw+4axqMt5ghZJ4w4ooQ/21gwSj/BL7/0AdGs3yZ5kYjz+/0+ryK9Ggcq/ReREGnzEImmPQIdEy9w1IbsS12Tiv8g6kFztCVERLso4ntHKMzkpzolVLqr7ukeRtg3OkJ+B9957DDDBdPFhzYGhjtPV/aLfhsr14e4IDr3sReQWL6hPkMTssQGXPsOqg1Yv/JJdrb9A6E2r661cGDcl2pCBqTbcozim/j5kT1I+60mKZzeMe0/QGktNbP

Steps to reproduce

click the checkbox. observe the {{cls}} value change and the checkbox not checking. If you remove {{cls}} from the template the box will check.

What is expected?

The view re renders with the updated string ref {{cls}} and the checkbox is checked.

What is actually happening?

click the checkbox. observe the cls value change and the checkbox not checking. If you remove {{cls}} from the template the box will check.

System Info

multiple systems / OS's

Any additional comments?

potentially related to this issue:
#8579

Explanation of cause from a member in the vue discord channel:

Clicking on the checkbox sets the checked state of the checkbox to true.
The click event happens.
Vue re-renders. The data bound to the v-model hasn't been updated yet, so when it re-renders the checkbox it sets it back to unchecked.
The change event happens, triggering the v-model. But that performs the update based on the current value of the checked property, which is now back to false.

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