mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-26 08:34:28 +02:00
fix editor auto focus (#1438)
current implement of auto focus is buggy, HTMLElement.focus method have no effect on selection state of editor, another re-render will cause editor blur unexpectedly.
This commit is contained in:
committed by
Ian Storm Taylor
parent
f3b1a806d7
commit
b3324db24c
@@ -92,6 +92,8 @@ class Content extends React.Component {
|
||||
*/
|
||||
|
||||
componentDidMount = () => {
|
||||
const { editor } = this.props
|
||||
|
||||
// Restrict scoped of `beforeinput` to mobile.
|
||||
if ((IS_IOS || IS_ANDROID) && SUPPORTED_EVENTS.beforeinput) {
|
||||
this.element.addEventListener('beforeinput', this.onNativeBeforeInput)
|
||||
@@ -100,7 +102,7 @@ class Content extends React.Component {
|
||||
this.updateSelection()
|
||||
|
||||
if (this.props.autoFocus) {
|
||||
this.element.focus()
|
||||
editor.focus()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user