Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
fix(SlateAsInputEditor): fix focus issue by overriding Slate onFocus …
Browse files Browse the repository at this point in the history
…method

Signed-off-by: cdr <[email protected]>
  • Loading branch information
qualitymanifest authored and jolanglinais committed Oct 31, 2019
1 parent 7c92bd8 commit 8f3390c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/SlateAsInputEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ const SlateAsInputEditor = React.forwardRef((props, ref) => {
onChange(value);
};

const onFocusHandler = (_event, editor, _next) => {
// see https://github.com/accordproject/markdown-editor/issues/162
setTimeout(editor.focus, 0);
};

return (
<div>
<ToolbarWrapper {...editorProps} id="slate-toolbar-wrapper-id" />
Expand All @@ -454,6 +459,7 @@ const SlateAsInputEditor = React.forwardRef((props, ref) => {
value={Value.fromJSON(value)}
readOnly={props.readOnly}
onChange={onChangeHandler}
onFocus={onFocusHandler}
schema={slateSchema}
plugins={props.plugins}
onBeforeInput={onBeforeInput}
Expand Down

0 comments on commit 8f3390c

Please sign in to comment.