Skip to content

Commit

Permalink
fix: cy.type('{enter}') submits the form correctly after Firefox 98.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Apr 12, 2022
1 parent 6fc1bed commit 053cffd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 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 @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 053cffd

Please sign in to comment.