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

fix(VCheckboxBtn): reset checked state when readonly is true #19861

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
RafalOsieka marked this conversation as resolved.
Show resolved Hide resolved
nextTick(() => group.forceUpdate())
Expand Down
Loading