Closed
Description
Current behavior:
Cypress 3.5.0 is no longer behaving the same way as executing outside of Cypress with regards to an input
with an onFocus
handler implemented as e => e.target.select()
(select-on-focus behavior). It does not appear to select the text (the onFocus
handler is called, though). The application code has not changed and works "in real life" but fails in Cypress. This worked in Cypress 3.4.1.
Desired behavior:
The behavior should be consistent with running outside of Cypress, as it was in previous versions.
Steps to reproduce: (app code and test code)
App code:
<input defaultValue="42" onFocus={e => e.target.select()} />
Test code:
cy.get('input')
.should('have.value', '42')
.click()
// input has just been focused so its value should now be selected
// (and thus typing would replace the value, not append to it)
.type('36')
// fail - input value is 4236
.should('have.value', '36');
Reproduction repository:
https://github.com/wKovacs64/cypress-350-select-on-focus
Versions
Cypress 3.5.0
Windows 10, Linux (Circle CI)
Chrome 78, Electron 73
Activity
kuceb commentedon Oct 24, 2019
@wKovacs64 thanks, I'm able to reproduce and working on getting a fix in for the next patch version
wKovacs64 commentedon Oct 24, 2019
Great, thanks @bkucera
cypress-bot commentedon 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.
cypress-bot commentedon 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.
cypress-bot commentedon Nov 5, 2019
Released in
3.6.0
.