mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 23:12:52 +02:00
Wrap scrolling logic in setTimeout (#847)
The native selection will be updated after componentDidMount or componentDidUpdate. Use setTimeout to queue scrolling to the last when the native selection has been updated to the correct value.
This commit is contained in:
@@ -180,12 +180,16 @@ class Node extends React.Component {
|
||||
if (selection.isBlurred) return
|
||||
if (!selection.hasEndIn(node)) return
|
||||
|
||||
// The native selection will be updated after componentDidMount or componentDidUpdate.
|
||||
// Use setTimeout to queue scrolling to the last when the native selection has been updated to the correct value.
|
||||
setTimeout(() => {
|
||||
const el = ReactDOM.findDOMNode(this)
|
||||
const window = getWindow(el)
|
||||
const native = window.getSelection()
|
||||
scrollToSelection(native)
|
||||
|
||||
this.debug('updateScroll', el)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user