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
Number inputs that are manually focused do not respect the caret position during cy.type()
#7170
Comments
This behavior happening all the way back to 3.4.1, so was not introduced in a recent version. Note: You never need to write ``should('exist') To reproduce
<html>
<body>
<button onclick="onClick()">Show input</button>
<script>
function onClick() {
let input = document.createElement('input')
// The type has to be a `number` for the test to fail
input.type = 'number'
input.value = 1
document.body.appendChild(input)
// The input needs to be forcibly focused for the test to fail
document.querySelector('input').focus()
}
</script>
</body>
</html>
it('can type in a number field correctly', () => {
cy.visit('./index.html')
cy.get('button').click()
cy.get('input')
.type('2')
// fails
.should('have.value', '12')
}) |
type()
ed in correctlycy.type()
The code for this is done in cypress-io/cypress#8515, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
I've set up a small repro app (link below) that has a button. When clicking on this button, an
<input type="number" value="1" />
is created and manually focused (by callingfocus()
on it).In my test, I click on this button, wait for the input to show up, and then attempt to type something into this input. Instead of appending typed characters to the end of the input (where the cursor is), Cypress appends them to the beginning of the input.
Desired behavior:
I expect the the typed character to be appended to the end of the input (where the cursor is), and the written test to pass.
Test code to reproduce
I've set up this repo that is a simplified version of my app and exhibits the issue:
https://github.com/madebysid/cypress-input-focus-issue
(I can fork https://github.com/cypress-io/cypress-test-tiny and set this up there instead if you prefer, but it seems very similar to what I have)
Versions
Cypress: 4.5.0
OS: macOS
Browser: Electron
Curiously enough, the test behaves as I expect (and passes) on Cypress 3.7.0. Cypress 3.8.0+ have this issue.
The text was updated successfully, but these errors were encountered: