mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 13:41:19 +02:00
Fix useFocused
not updated when calling ReactEditor.focus
(#5593)
This commit is contained in:
5
.changeset/shiny-numbers-matter.md
Normal file
5
.changeset/shiny-numbers-matter.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Fix: Calling `ReactEditor.focus` doesn't update `useFocused` when running in @testing-library/react
|
@@ -447,8 +447,10 @@ export const ReactEditor: ReactEditorInterface = {
|
||||
Transforms.select(editor, Editor.start(editor, []))
|
||||
editor.onChange()
|
||||
}
|
||||
el.focus({ preventScroll: true })
|
||||
// IS_FOCUSED should be set before calling el.focus() to ensure that
|
||||
// FocusedContext is updated to the correct value
|
||||
IS_FOCUSED.set(editor, true)
|
||||
el.focus({ preventScroll: true })
|
||||
}
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user