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

RichText: fix wordwise selection on Windows #14184

Merged
merged 3 commits into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,14 @@ export class RichText extends Component {
/**
* Handles a keydown event.
*
* @param {KeyboardEvent} event The keydown event.
* @param {SyntheticEvent} event A synthetic keyboard event.
*/
onKeyDown( event ) {
const { keyCode, shiftKey, altKey, metaKey } = event;
const { keyCode, shiftKey, altKey, metaKey, ctrlKey } = event;

if (
! shiftKey && ! altKey && ! metaKey &&
// Only override left and right keys without modifiers pressed.
! shiftKey && ! altKey && ! metaKey && ! ctrlKey &&
( keyCode === LEFT || keyCode === RIGHT )
) {
this.handleHorizontalNavigation( event );
Expand Down Expand Up @@ -661,6 +662,13 @@ export class RichText extends Component {
}
}

/**
* Handles horizontal keyboard navigation when no modifiers are pressed. The
* navigation is handled separately to move correctly around format
* boundaries.
*
* @param {SyntheticEvent} event A synthetic keyboard event.
*/
handleHorizontalNavigation( event ) {
const value = this.createRecord();
const { formats, text, start, end } = value;
Expand Down