You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 6, 2023. It is now read-only.
Deprecated the coarse onArrowUp et al key handler props on DraftEditor.react to make it possible to produce editor commands from these keys
Summary:
Previously, it was impossible to do this:
```
function mapKeysToEditorCommands(e) {
if (mentionsAutocompleteIsOpen) {
switch (e.keyCode) {
case Keys.UP:
return 'MentionsAutocomplete/select-previous';
case Keys.DOWN:
return 'MentionsAutocomplete/select-next';
}
}
return getDefaultKeyBinding(e);
}
<DraftEditor
keyBindingFn={mapKeysToEditorCommands}
...
/>
```
…because we didn't give TAB, ESCAPE, LEFT, UP, RIGHT, or DOWN a chance to produce a command name.
This pull request:
1. deprecates the prop-based key handlers (`onUpArrow` et al.) and encourages people to move their custom key logic into a `keyBindingFn`, and
2. lets the named keypresses fall through to the `keyBindingFn` whenever a prop-based key handler isn't supplied.
3. Updates the homepage and the rich text example.

Closes#1637
Differential Revision: D6864155
fbshipit-source-id: 23efb4caac25b1bc867350a1212f142b5b3ce7ab
This prop lets you handle key events directly and provides an opportunity to return custom editor commands. You can find a more detailed explanation of this [here](/docs/advanced-topics-key-bindings.html).
299
-
300
-
#### onLeftArrow
301
-
```
302
-
onLeftArrow?: (e: SyntheticKeyboardEvent) => void
303
-
```
274
+
This prop function exposes `keyDown` events to a handler of your choosing. If an
275
+
event of interest happens, you can perform custom logic and/or return a string
276
+
corresponding to a `DraftEditorCommand` or a custom editor command of your
277
+
own creation. Example: At Facebook, this is used to provide keyboard interaction
278
+
for the mentions autocomplete menu that appears when typing a friend's name.
0 commit comments