-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(driver): fix firefox moveToStart,moveToEnd, add tests #7970
Conversation
Thanks for taking the time to open a PR!
|
The cause of failure in #6203 was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test should go into the type_special_chars_spec.js
file. I know our type spec was getting out of hand and we were trying to split some things out.
I'm planning to open a docs PR to document this here: cypress-io/cypress-documentation#2991
I'd like to understand a bit more about how this is different from end
and home
chars. It seems that this test functions exactly the same when replaced with home
and end
. If there is a difference in behavior from home
and end
, I'd like if that were covered in the test.
As far as I can tell though, I think the only difference is the association with the actual home
and end
key issuing the which
, key
and keyCode
, which moveToStart
and moveToEnd
wouldn't do. Can I get some clarification on this?
I put it in But they're I'll move them to When the text is a single line like Let's say there is a text like this in
With
With
When I was migrating the test, I thought the tests reflect this difference. But I read it again now, and it didn't. I'll fix the test. |
@sainthkh Awesome, yah I wanted more clarification for docs as well. This is helpful and the modified test to test this would be great. Yah, I was just thinking the other day about special chars, how we've kind of mixed in special functions into this? Like selectAll and moveToEnd. I may split these up in the docs to be clearer that they don't correspond to a single character key. cypress-io/cypress-documentation#2991 |
After trying to write tests that show the difference between I had to fix them, too. The cause was cypress/packages/driver/src/dom/selection.ts Lines 565 to 580 in 3197056
It's because it doesn't select to the start or the end when the text becomes long. You can check this behavior at the example here. I had to use And I also met a bug(?) in Firefox. (I cannot say for sure here because these |
0e4ed47
to
bfea619
Compare
Flaky failure. Coding is done. I'm now trying to write some notes for the reviewer about why the change was necessary and what are changed. All of us thought this PR would be done by adding some tests. But the problem was much bigger than that. |
Besides the bug caused by
|
Dismissing my previous review for more thorough code reviews.
@sainthkh sorry for taking so long to get to this. Let me know your thoughts on my most recent changes. Basically kept the old code but replaced I think we shouldn't try to handle the firefox newline oddity, since it actually happens if you ctrl+a leftarrow manually. |
I tried it on this editor on firefox. But there was no newline between I opened And does this happen when you use |
@sainthkh those are textareas, I'm referring to contenteditables (divs with contenteditable attr) |
@sainthkh ok, I realize we do need to find a way to avoid firefox not removing the newline when we moveToStart/End. Looking into how to do that without having to mutate innerText, might be able to just fix the selection to be inside the proper node |
We cannot use So, I used // FireFox doesn't clear empty <br> in the content editable.
if (Cypress.browser.family === 'firefox' && root.innerText === '\n') {
root.innerText = ''
} The code above was necessary to solve the failures in driver firefox tests. |
Closes add tests for {moveToStart} / {moveToEnd} special sequences #5502
Fix issue with moveToStart/End only moving to end of line instead of whole text editable in firefox
It's because it doesn't select to the start or the end when the text becomes long. You can check this behavior at the example here.
I had to use collapse functions. They work in all modern browsers.
User facing changelog
Added tests for undocumented features, {moveToStart} and {moveToEnd}.
Additional details
How has the user experience changed?
N/A
PR Tasks
cypress-documentation
? document movetoend and movetostart special chars for type cypress-documentation#2991