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

[SuperEditor][Web] Fix option + arrow key selection changes (Resolves #2415) #2418

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

angelosilvestre
Copy link
Collaborator

[SuperEditor][Web] Fix option + arrow key selection changes. Resolves #2415

Steps to reproduce the behavior:

  1. Run Example app on Chrome
  2. Place cursor at beginning of line
  3. Use CMD + SHIFT + RIGHT ARROW to select until the end of line
  4. Use SHIFT + ALT + LEFT ARROW to remove last word from selection

When doing this the caret moves to the beginning of the line:

Screen.Recording.2024-11-19.at.11.37.40.AM.mov

This seems to be caused by IME deltas. I ran the example editor without any keyboard handlers and the issue also happens. It might be related to the same issue fixed in #2327, where the line breaks on the browser HTML input are different from Flutter.

Currently, we have a keyboard handler that sends the event back to the IME when pressing LEFT or RIGHT ARROW at the middle of the text. I modified this handler to not do that if ALT is pressed.

Screen.Recording.2024-11-20.at.18.58.37.mov

This PR adds tests for this, but to effectively test these web keyboard interactions we would need an integration test that runs on the browser.

@@ -523,6 +523,126 @@ void main() {
),
);
});

testWidgetsOnMacDesktopAndWeb('SHIFT + OPTION + LEFT ARROW: removes upstream word from selection',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terms "upstream" and "downstream" are used incorrectly in this test name and the next. This test deselects the last word in the line - that's downstream. The other test deselects the first word in the line - that's upstream.

But we probably don't need to use those words at all. It's not obvious what they mean.

Instead we can say "SHIFT + OPTION + LEFT ARROW: deselects word at end of line after selecting the whole line from start to end"

and "SHIFT + OPTION + RIGHT ARROW: deselects word at start of line after selecting the whole line from end to start"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor

@matthew-carroll matthew-carroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matthew-carroll matthew-carroll merged commit d5d0f8d into main Nov 27, 2024
12 of 14 checks passed
@matthew-carroll matthew-carroll deleted the 2415_fix-shift-option-selection-web branch November 27, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - CMD+Arrow + Selection Change not working correctly
2 participants