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][3.5.2] VCheckboxBtn - double click is required when @update:model-value does not update model-value #19137

Closed
ro-cf opened this issue Jan 31, 2024 · 1 comment · Fixed by #19861 or Enterprise-CMCS/cmcs-eregulations#1360 · May be fixed by YoutacRandS-VA/desec-stack#2 or manastalukdar/manastalukdar.github.io#411
Labels
C: VCheckbox VCheckbox T: bug Functionality that does not work as intended/expected

Comments

@ro-cf
Copy link

ro-cf commented Jan 31, 2024

Environment

Vuetify Version: 3.5.2
Vue Version: 3.4.15
Browsers: Chrome 120.0.0.0
OS: Windows

Steps to reproduce

Some notes to the playground:

  • Checkbox #1 is where the problem will occur.
  • Checkbox #2 is used to control the behaviour of the Checkbox #1

Steps:

  1. Click on Checkbox #2
  2. Click on Checkbox #1
    • state should not change, as @update:model-update event handler is doing nothing
  3. Click on Checkbox #2
  4. Click on Checkbox #1

Expected Behavior

After step 4, the Checkbox #1 should be checked

Actual Behavior

After step 4, the Checkbox #1 is unchecked.

Additional click is required on the checkbox to correctly update the value.

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

Observations:

  • if step 4 is executed ODD number of times, then the bug happens
  • if step 4 is executed EVEN number of times, then there everything is ok

Probably some internal state in VCheckboxBtn is updated. But if the update:model-value handler does not update the model-value, then there is mismatch with internal state and modelValue.

Workarounds

I have found the following workaround - using @click.prevent instead of the @update:mode-value (as can be seen below), so it's not a big problem, but the issue still remains, that it can happen that internal state of checkbox component is not aligned with the modelValue

<v-checkbox-btn
  :model-value="checkboxState"
  @click.prevent="handleCheckboxStateUpdate(!checkboxState)"
/>
@johnleider
Copy link
Member

A better way to do this would be using the readonly prop: https://play.vuetifyjs.com/#eNqNUcFOwzAM/RUrHAYSbbXBLqVDQly5IU6UQ5qmrFqaRIlbgab9O266qmUCbbfYfn7P7+V9z7wTyZO1cddKlrIMZWMVR/mYa4Csi7i14RkKYTTyWkt3bA3NrRS7wnxFBeqxDaB4IdUmZ8/HKVwt05xN8y5qTBkQ4/4rkuwckjrJS6PVN4H81rSqfDFiNxK+2ZLwflpI6KizZ02yFzD+5WI1c9ErBrXkNJq+MySXJbNEqfTC1RbBS2wt0etPYkfSDGt1Y41D2IOTFRygcqaBBX3MYnBGGh7hV16w6bHXFVde3jxMoH/dnS5kyXAR6bPDLbuL7+PlmvWPdbxiHz8iB660

With that being said, it still has the same issue. It's more than likely because a state is being set when you click on checkbox 1.

@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VCheckbox VCheckbox and removed S: triage labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment