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

Focusing radio input and then using .type changes value #15913

Closed
kylecombes opened this issue Apr 9, 2021 · 4 comments · Fixed by #16154
Closed

Focusing radio input and then using .type changes value #15913

kylecombes opened this issue Apr 9, 2021 · 4 comments · Fixed by #16154
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️

Comments

@kylecombes
Copy link

Current behavior

After focusing an input[type="radio"], the value attribute of that element change be changed using .type.

Desired behavior

Cypress should recognize that radio inputs cannot have their value changed by the user.

Test code to reproduce

Given the following HTML (saved in test.html):

<html lang="en">
  <body>
    <input id="my-radio" type="radio" value="foo" name="Foo"/>
    <label for="my-radio">Foo</label>
  </body>
</html>

the following test fails:

describe('My radio', () => {
  it('value does not change when focusing and typing', () => {
    cy.visit('/test.html');
    cy.get('input').should('have.value', 'foo').type('bar').should('have.value', 'foo');
  });
});

Screen Shot 2021-04-09 at 12 24 06 PM

Versions

  • Cypress v7.0.1
  • Chrome 89.0.4389.114
  • macOS 10.15.7
@sainthkh
Copy link
Contributor

Right, I ran your example and it was reproducible.

I clicked the radio button manually and typed the text and saw that it doesn't change the value. cy.type() doesn't reflect the browser behavior.

@sainthkh sainthkh added stage: ready for work The issue is reproducible and in scope topic: cy.type ⌨️ pkg/driver This is due to an issue in the packages/driver directory labels Apr 14, 2021
@kylecombes
Copy link
Author

Additionally, pressing the space bar when the radio input is focused in the browser selects the option (see WAI-ARIA guidelines for RadioGroup). I was trying to test that behavior and that's how I discovered this issue.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Apr 23, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Apr 26, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 26, 2021

The code for this is done in cypress-io/cypress#16154, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 26, 2021

Released in 7.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants