mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-03 12:12:39 +02:00
Avoid selection reconciliation on Android when there are pending changes
This commit is contained in:
5
.changeset/bugfix-android-selection.md
Normal file
5
.changeset/bugfix-android-selection.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Fixed a bug on Android where Slate would attempt to reconcile the DOM selection with Slate's internal selection while there are pending diffs or while the pending diffs are being flushed, which could result in an error being thrown because of a mismatch between the state of the DOM and Slate's internal representation if they were out of sync.
|
@@ -266,16 +266,20 @@ export const Editable = (props: EditableProps) => {
|
||||
NODE_TO_ELEMENT.delete(editor)
|
||||
}
|
||||
|
||||
if (
|
||||
!ReactEditor.isFocused(editor) ||
|
||||
androidInputManager?.hasPendingChanges() ||
|
||||
androidInputManager?.isFlushing()
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
// Make sure the DOM selection state is in sync.
|
||||
const { selection } = editor
|
||||
const root = ReactEditor.findDocumentOrShadowRoot(editor)
|
||||
const domSelection = root.getSelection()
|
||||
|
||||
if (
|
||||
!domSelection ||
|
||||
!ReactEditor.isFocused(editor) ||
|
||||
androidInputManager?.hasPendingAction()
|
||||
) {
|
||||
if (!domSelection) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user