From 3d281b34957cc0c1d9267652a42ec66534f97bdb Mon Sep 17 00:00:00 2001 From: KHeo Date: Tue, 12 Apr 2022 16:40:17 +0900 Subject: [PATCH 1/2] fix: cy.type('{enter}') submits the form correctly after Firefox 98. --- packages/driver/src/cy/commands/actions/type.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/driver/src/cy/commands/actions/type.ts b/packages/driver/src/cy/commands/actions/type.ts index a00836000ef6..5d54ca77f448 100644 --- a/packages/driver/src/cy/commands/actions/type.ts +++ b/packages/driver/src/cy/commands/actions/type.ts @@ -174,6 +174,8 @@ export default function (Commands, Cypress, cy, state, config) { } const type = function () { + const isFirefoxBefore98 = Cypress.isBrowser('firefox') && Cypress.browserMajorVersion() < 98 + const simulateSubmitHandler = function () { const form = options.$el.parents('form') @@ -235,7 +237,8 @@ export default function (Commands, Cypress, cy, state, config) { // when we send {Enter} KeyboardEvent to the input fields. // Because of that, we don't have to click the submit buttons. // Otherwise, we trigger submit events twice. - if (!Cypress.isBrowser('firefox')) { + // But after Firefox 98, submit event isn't automatically fired. + if (!isFirefoxBefore98 || !Cypress.isBrowser('firefox')) { // issue the click event to the 'default button' of the form // we need this to be synchronous so not going through our // own click command @@ -274,7 +277,6 @@ export default function (Commands, Cypress, cy, state, config) { const isContentEditable = $elements.isContentEditable(options.$el.get(0)) const isTextarea = $elements.isTextarea(options.$el.get(0)) - const isFirefoxBefore98 = Cypress.isBrowser('firefox') && Cypress.browserMajorVersion() < 98 const fireClickEvent = (el) => { const ctor = $dom.getDocumentFromElement(el).defaultView!.PointerEvent From 8539d14de532c9558495cfdf81559bd1430a484f Mon Sep 17 00:00:00 2001 From: KHeo Date: Thu, 14 Apr 2022 15:40:15 +0900 Subject: [PATCH 2/2] simplify condition. --- packages/driver/src/cy/commands/actions/type.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/driver/src/cy/commands/actions/type.ts b/packages/driver/src/cy/commands/actions/type.ts index 5d54ca77f448..e131970b38f8 100644 --- a/packages/driver/src/cy/commands/actions/type.ts +++ b/packages/driver/src/cy/commands/actions/type.ts @@ -233,12 +233,11 @@ export default function (Commands, Cypress, cy, state, config) { return } - // In Firefox, submit event is automatically fired + // Before Firefox 98, submit event is automatically fired // when we send {Enter} KeyboardEvent to the input fields. // Because of that, we don't have to click the submit buttons. // Otherwise, we trigger submit events twice. - // But after Firefox 98, submit event isn't automatically fired. - if (!isFirefoxBefore98 || !Cypress.isBrowser('firefox')) { + if (!isFirefoxBefore98) { // issue the click event to the 'default button' of the form // we need this to be synchronous so not going through our // own click command