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

Escape input event is ignored when using cy.type('{esc}') #21313

Open
davidmunechika opened this issue May 3, 2022 · 5 comments
Open

Escape input event is ignored when using cy.type('{esc}') #21313

davidmunechika opened this issue May 3, 2022 · 5 comments
Labels
E2E Issue related to end-to-end testing stale no activity on this issue for a long period topic: cy.type ⌨️ type: bug

Comments

@davidmunechika
Copy link
Contributor

Current behavior

If the escape key has been implemented with functionality that changes the text of an input field (i.e. hitting escape when focused on an input field clears the text in the input), this behavior is not replicated correctly when using cy.type('{esc}').

The Escape input event is being ignored at this line:

shouldIgnoreEvent('input', key.events) ||
this.fireSimulatedEvent(el, 'input', key, options)

because input is getting set to false here:

if (!shouldUpdateValue(el, key, options)) {
debug('skip typing key', false)
key.events.input = false
return
}

because the Escape event doesn't have a text field associaed with it so shouldUpdateValue is returning false (even though in this specific case, we want Escape to be able to update the value).

Desired behavior

cy.type('{esc}') should simulate the same behavior experienced by the user when hitting Escape manually.

Test code to reproduce

Replace realType() with type() and the test will fail.

it('clears the filter if the user presses ESC key', function () {
cy.findByLabelText('Search Specs').type('asdf')
cy.findByLabelText('Search Specs').realType('{esc}')
cy.findByLabelText('Search Specs')
.should('have.value', '')
cy.get('[data-cy="spec-item"]')
.should('have.length', 14)
})

Cypress Version

10.0.0

Other

No response

@github-actions
Copy link
Contributor

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@github-actions github-actions bot added the stale no activity on this issue for a long period label May 12, 2023
@niketpathak
Copy link

niketpathak commented May 19, 2023

It's been over a year, and this still doesn't seem to work. Tested on the latest version as of today (v12.12.0)

@cypress-app-bot cypress-app-bot removed the stale no activity on this issue for a long period label May 22, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 27, 2024
@niketpathak
Copy link

Been 2 years now ? Can the Cypress team look into this ?

@cypress-app-bot cypress-app-bot removed the stale no activity on this issue for a long period label May 28, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing stale no activity on this issue for a long period topic: cy.type ⌨️ type: bug
Projects
None yet
Development

No branches or pull requests

8 participants