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

Typing a modifier key anywhere removes selected text from an input in 3.5.0 #5439

Closed
dwelle opened this issue Oct 24, 2019 · 4 comments · Fixed by #5496
Closed

Typing a modifier key anywhere removes selected text from an input in 3.5.0 #5439

dwelle opened this issue Oct 24, 2019 · 4 comments · Fixed by #5496
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@dwelle
Copy link

dwelle commented Oct 24, 2019

Current behavior:

Typing a modifier key into an input anywhere removes selected text in an active input.

Desired behavior:

Shouldn't touch input value at all.

Steps to reproduce: (app code and test code)

describe('test', () => {
    it('test', () => {
        cy.document().then(doc => {
            doc.body.innerHTML = `
                <textarea class="one">hello</textarea>
                <textarea class="two">hello</textarea>
                <input class="three" value="hello">
            `;
        });

        // (1) clears whole textarea
        cy.get('.one').type('{selectall}').type('{ctrl}');

        // (2) clears whole textarea
        cy.get('.two').type('{selectall}');
        cy.get('body').type('{ctrl}');

        // (3) removes last letter
        cy.get('.three')
            .focus()
            .then( $input => {
                $input[0].selectionStart = 4;
                $input[0].selectionEnd = 5;
            })
            .type('{ctrl}');
    });
});

Versions

  • Cypress 3.5.0, Win 7, chrome stable 77 (headed) & chrome canary 73 (headless)
  • It's possible a regression in older cypress version (I've migrated from 3.3.13.5.0 directly)
@dwelle dwelle changed the title Typing a modifier key into an input removes selected text Typing a modifier key anywhere removes selected text from an input Oct 24, 2019
@jennifer-shehane
Copy link
Member

I can confirm that this behavior has changed from 3.4.1 to 3.5.0.

Test exhibiting change.

describe('test', () => {
  it('test', () => {
    cy.document().then((doc) => {
      doc.body.innerHTML = `
        <textarea class="one">hello</textarea>
        <textarea class="two">hello</textarea>
        <input class="three" value="hello">
      `
    })

    // (1) clears whole textarea
    cy.get('.one').type('{selectall}').type('{ctrl}')

    // (2) clears whole textarea
    cy.get('.two').type('{selectall}')
    cy.get('body').type('{ctrl}')

    // (3) removes last letter
    cy.get('.three')
      .focus()
      .then(($input) => {
        $input[0].selectionStart = 4
        $input[0].selectionEnd = 5
      })
      .type('{ctrl}')
      .should('have.value', 'hello')
  })
})

3.4.1

Screen Shot 2019-10-24 at 9 53 03 AM

3.5.0

Screen Shot 2019-10-24 at 9 53 53 AM

This does appear to me to be a bug - since doing this behavior manually does not clear the selected value when pressing {ctrl} on the keyboard. This may be related to this change: #5424 @bkucera will have a lot more insight into this however.

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Oct 24, 2019
@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Oct 24, 2019
@jennifer-shehane jennifer-shehane changed the title Typing a modifier key anywhere removes selected text from an input Typing a modifier key anywhere removes selected text from an input in 3.5.0 Oct 24, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: needs investigating Someone from Cypress needs to look at this labels Oct 28, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 29, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 29, 2019

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

1 similar comment
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 29, 2019

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

@jennifer-shehane
Copy link
Member

Released in 3.6.0

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0
Projects
None yet
3 participants