Skip to content

Commit

Permalink
Fixed triple click workaround breaking void elements selection (#5451)
Browse files Browse the repository at this point in the history
* Fixed tripple click workaround breaking void selection

* Add changesets

* Fix ts error

* Make code style more consistent
  • Loading branch information
gtluszcz committed Jun 16, 2023
1 parent bac37ca commit 12ff246
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/popular-shrimps-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': minor
---

Fixed occasional crashes when selecting void elements in Chrome
3 changes: 2 additions & 1 deletion packages/slate-react/src/plugin/react-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,8 @@ export const ReactEditor: ReactEditorInterface = {
// will cause `toSlatePoint` to throw an error. (2023/03/07)
if (
'getAttribute' in focusNode &&
(focusNode as HTMLElement).getAttribute('contenteditable') === 'false'
(focusNode as HTMLElement).getAttribute('contenteditable') === 'false' &&
(focusNode as HTMLElement).getAttribute('data-slate-void') !== 'true'
) {
focusNode = anchorNode
focusOffset = anchorNode.textContent?.length || 0
Expand Down

0 comments on commit 12ff246

Please sign in to comment.