Skip to content

Commit

Permalink
fix(VCheckboxBtn): reset checked state when readonly is true (#19861)
Browse files Browse the repository at this point in the history
fixes #19137
  • Loading branch information
RafalOsieka committed May 29, 2024
1 parent 64acd01 commit ed2f0fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,17 @@ describe('VCheckboxBtn', () => {

cy.get('input').should('have.attr', 'aria-checked', 'mixed')
})

it('should not update input checked state when it is readonly', () => {
const model = ref(false)
cy.mount(() => (
<VCheckboxBtn v-model={ model.value } readonly />
))

cy.get('.v-checkbox-btn').click(20, 20)

cy.get('input').should('not.be.checked').then(() => {
expect(model.value).to.be.false
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,16 @@ export const VSelectionControl = genericComponent<new <T>(
}

function onInput (e: Event) {
if (!isInteractive.value) return
if (!isInteractive.value) {
if (input.value) {
// model value is not updated when input is not interactive
// but the internal checked state of the input is still updated,
// so here it's value is restored
input.value.checked = model.value
}

return
}

if (props.readonly && group) {
nextTick(() => group.forceUpdate())
Expand Down

0 comments on commit ed2f0fa

Please sign in to comment.