Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Right and Left Arrow Event Handling #1384

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions docs/APIReference-Editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,21 @@ onTab?: (e: SyntheticKeyboardEvent) => void
onUpArrow?: (e: SyntheticKeyboardEvent) => void
```

#### onRightArrow
```
onRightArrow?: (e: SyntheticKeyboardEvent) => void
```

#### onDownArrow
```
onDownArrow?: (e: SyntheticKeyboardEvent) => void
```

#### onLeftArrow
```
onLeftArrow?: (e: SyntheticKeyboardEvent) => void
```

### Mouse events

### onFocus
Expand Down
2 changes: 2 additions & 0 deletions src/component/base/DraftEditorProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export type DraftEditorProps = {
onEscape?: (e: SyntheticKeyboardEvent<>) => void,
onTab?: (e: SyntheticKeyboardEvent<>) => void,
onUpArrow?: (e: SyntheticKeyboardEvent<>) => void,
onRightArrow?: (e: SyntheticKeyboardEvent<>) => void,
onDownArrow?: (e: SyntheticKeyboardEvent<>) => void,
onLeftArrow?: (e: SyntheticKeyboardEvent<>) => void,

onBlur?: (e: SyntheticEvent<>) => void,
onFocus?: (e: SyntheticEvent<>) => void,
Expand Down
6 changes: 6 additions & 0 deletions src/component/handlers/edit/editOnKeyDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,15 @@ function editOnKeyDown(editor: DraftEditor, e: SyntheticKeyboardEvent<>): void {
case Keys.UP:
editor.props.onUpArrow && editor.props.onUpArrow(e);
return;
case Keys.RIGHT:
editor.props.onRightArrow && editor.props.onRightArrow(e);
return;
case Keys.DOWN:
editor.props.onDownArrow && editor.props.onDownArrow(e);
return;
case Keys.LEFT:
editor.props.onLeftArrow && editor.props.onLeftArrow(e);
return;
case Keys.SPACE:
// Handling for OSX where option + space scrolls.
if (isChrome && isOptionKeyCommand(e)) {
Expand Down