Skip to content

Commit

Permalink
Update IS_FIREFOX_LEGACY flag to prevent FF crash (#4237)
Browse files Browse the repository at this point in the history
* Update IS_FIREFOX_LEGACY flag to prevent FF crash

#4118 and #4150 introduced IS_FIREFOX_LEGACY, but this block of code was not updated to reflect that. This breaks insertion of emoji and unicode characters in slate-react. This change fixes #3855.

* Update editable.tsx

* Create forty-mails-roll.md

* Update editable.tsx

Apologies, in my tests I was using yarn patch and didn't need to modify the import statement, hopefully this will pass CI now.

Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
  • Loading branch information
dylans and ianstormtaylor authored May 5, 2021
1 parent 3b3c94a commit 623960a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/forty-mails-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

Fixed text insertion logic to prevent crashing in newer Firefox versions.
3 changes: 2 additions & 1 deletion packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import useChildren from '../hooks/use-children'
import Hotkeys from '../utils/hotkeys'
import {
IS_FIREFOX,
IS_FIREFOX_LEGACY,
IS_SAFARI,
IS_EDGE_LEGACY,
IS_CHROME_LEGACY,
Expand Down Expand Up @@ -659,7 +660,7 @@ export const Editable = (props: EditableProps) => {
// aren't correct and never fire the "insertFromComposition"
// type that we need. So instead, insert whenever a composition
// ends since it will already have been committed to the DOM.
if (!IS_SAFARI && !IS_FIREFOX && event.data) {
if (!IS_SAFARI && !IS_FIREFOX_LEGACY && event.data) {
Editor.insertText(editor, event.data)
}
}
Expand Down

0 comments on commit 623960a

Please sign in to comment.