Some regressions were introduced in 3.5 in type() behavior when interacting with selection (selectall / unselect).
The issue happens in a rich text editor where we are making a text bold by triggering:
{selectall} to select the typed text{ctrl}B one time to start{ctrl}B a second time to stopIt seems:
{rightarrow}.{ctrl} is ignored, only B is triggeredIn a rich text editor supporting this command.
Hello{selectall}{ctrl}B{rightarrow}{ctrl}B world!_Work in progress, currently trying to generate a minimum reproduction._
Introduced in Cypress 3.5, still happening in 3.6. Linux / Mac OS.
Thanks @znarf , I inadvertently introduced a breaking change with 3.5.0, with the decision to _not insert text_ if a non-shift modifier key is held down (what the browser does).
The problem is the cy.type API is a little obtuse and, for example, the ctrl key is not just held down for the next character, but for the entire rest of the typing sequence.
I now realize that this breaks a lot of tests, since users might not write the type string wanting/knowing the modifiers are held down for the entire rest of the type.
I'll open up a PR to revert to pre 3.5.0 behavior
The code for this is done in cypress-io/cypress#5637, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 3.6.1.
@Bkucera It's still failing but the behavior is different.
CI run: https://circleci.com/gh/opencollective/opencollective-frontend/55853
Hello{selectall}{ctrl}B{rightarrow}{ctrl}B world!Looks like {ctrl}B is triggered as B. Reopen?
apologies @znarf, Would you happen to know if you're using .preventDefault on the 'B' to prevent it from typing? I am not sure why the B would not be typed prior to 3.5.0 unless that is the case, but I'll check it out.
It would help if you could screenshot the cy.type events table that gets logged to the browser console when you click the command log. Could you provide a screenshot for the event table in <3.5.0 ?
Hi @Bkucera, I'm working with @znarf on Open Collective.
We don't preventDefault in our code, but the library we're using - react-quill - may.
Here's a screenshot of the logs in console:


I've been able to make it work on 3.6.1 by splitting in multiple cy.type:
cy.get('[data-cy="HTMLEditor"] .ql-editor').type('Hello');
cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{selectall}');
cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{ctrl}B');
cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{rightarrow}');
cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{ctrl}B');
cy.get('[data-cy="HTMLEditor"] .ql-editor').type(' world!');
@Betree so in 3.4.1 if you have two of the same modifiers in a key string, we simply ignore the second one, since we treat it as still being held down. In 3.5.0+ we send a second keydown, which is causing the bug. If you remove the second ctrl from your type string, it should fix the issue. I'll open another PR to fix this and revert to <3.5.0 behavior, but this does show how our .type API is confusing for users. (notice
in the 3.4.1 screenshot how the ctrl modifier is held down after the first press, and there is no second ctrl keydown)
We should probably implement a way to type one modifier key combination + release without having to break up into multiple type commands, something like:
cy.type('{ctrl+b}hello{ctrl+b}world')
cy.type('{ctrl+b}hello{ctrl+b}world') looks very clear and easy to read, that' a good idea!
The code for this is done in cypress-io/cypress#5696, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 3.7.0.