diff --git a/packages/driver/cypress/e2e/commands/actions/check.cy.js b/packages/driver/cypress/e2e/commands/actions/check.cy.js
index 323e6773cf..6190444d37 100644
--- a/packages/driver/cypress/e2e/commands/actions/check.cy.js
+++ b/packages/driver/cypress/e2e/commands/actions/check.cy.js
@@ -71,6 +71,21 @@ describe('src/cy/commands/actions/check', () => {
})
})
+ // https://github.com/cypress-io/cypress/issues/19098
+ it('removes indeterminate prop when checkbox is checked', () => {
+ const intermediateCheckbox = $(``)
+
+ intermediateCheckbox.prop('indeterminate', true)
+
+ $('body').append(intermediateCheckbox)
+
+ cy.get(':checkbox[name=\'indeterminate\']').check().then(($checkbox) => {
+ const hasIndeterminate = $checkbox.prop('indeterminate')
+
+ expect(hasIndeterminate).to.be.false
+ })
+ })
+
it('is a noop if already checked', () => {
const checkbox = ':checkbox[name=\'colors\'][value=\'blue\']'
@@ -839,6 +854,21 @@ describe('src/cy/commands/actions/check', () => {
})
})
+ // https://github.com/cypress-io/cypress/issues/19098
+ it('removes indeterminate prop when checkbox is unchecked', () => {
+ const indeterminateCheckbox = $(``)
+
+ indeterminateCheckbox.prop('indeterminate', true)
+
+ $('body').append(indeterminateCheckbox)
+
+ cy.get(':checkbox[name=\'indeterminate\']').uncheck().then(($checkbox) => {
+ const hasIndeterminate = $checkbox.prop('indeterminate')
+
+ expect(hasIndeterminate).to.be.false
+ })
+ })
+
it('unchecks a checkbox', () => {
cy.get('[name=birds][value=cockatoo]').uncheck().then(($checkbox) => {
expect($checkbox).not.to.be.checked
diff --git a/packages/driver/src/cy/commands/actions/check.ts b/packages/driver/src/cy/commands/actions/check.ts
index 490bbd3559..d882ed0808 100644
--- a/packages/driver/src/cy/commands/actions/check.ts
+++ b/packages/driver/src/cy/commands/actions/check.ts
@@ -113,6 +113,13 @@ const checkOrUncheck = (Cypress, cy, type, subject, values: any[] = [], userOpti
cy.ensureVisibility($el, options._log)
}
+ // if the checkbox is in an indeterminate state, checking or unchecking should set the
+ // prop to false to move it into a "determinate" state
+ // https://github.com/cypress-io/cypress/issues/19098
+ if ($el.prop('indeterminate')) {
+ $el.prop('indeterminate', false)
+ }
+
if (options._log) {
const inputType = $el.is(':radio') ? 'radio' : 'checkbox'