1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 05:01:17 +02:00

Fix issue with ReactEditor.focus + tests (#5527)

* Fix issue with slate-react static ReactEditor.focus method

This will make sure we don't try to focus the editor while it's in the midst of applying operations.
If this is the case, retry setting focus in the next tick.

* Replace react-test-renderer with @testing-library/react

We need to be able to test against window features, like the DOM selection.
@testing-library/react has a very similar API, but have also these features,
which react-test-renderer is missing.

* Rewrite tests for @testing-library/react

This will rewrite the existing tests for Editable and move them into a own file.

* Add tests for ReactEditor.focus

* Add changeset
This commit is contained in:
Per-Kristian Nordnes
2023-11-10 17:19:10 +01:00
committed by GitHub
parent f9cca97f00
commit fc081816e0
7 changed files with 541 additions and 252 deletions

View File

@@ -0,0 +1,7 @@
---
'slate-react': minor
---
Fixes a bug with `ReactEditor.focus` where it would throw an error if the editor was in the middle of applying pending operations.
With this change, setting focus will be retried until the editor no longer has any pending operations.
Calling `ReactEditor.focus` on a editor without a current selection, will now make a selection in the top of the document.