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: cy.type('{enter}') on <input> elements submits the form correctly after Firefox 98. #21042

Merged
merged 2 commits into from Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/driver/src/cy/commands/actions/type.ts
Expand Up @@ -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')

Expand Down Expand Up @@ -231,11 +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.
if (!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
Expand Down Expand Up @@ -274,7 +276,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
Expand Down