From 623960a7d14103b8cebe667019b4de5f8ad1fd61 Mon Sep 17 00:00:00 2001 From: Dylan Schiemann Date: Wed, 5 May 2021 16:56:10 -0700 Subject: [PATCH] Update IS_FIREFOX_LEGACY flag to prevent FF crash (#4237) * 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 --- .changeset/forty-mails-roll.md | 5 +++++ packages/slate-react/src/components/editable.tsx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/forty-mails-roll.md diff --git a/.changeset/forty-mails-roll.md b/.changeset/forty-mails-roll.md new file mode 100644 index 0000000000..088ab2ce83 --- /dev/null +++ b/.changeset/forty-mails-roll.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Fixed text insertion logic to prevent crashing in newer Firefox versions. diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index f2a8a22faf..e08d2ebd5d 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -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, @@ -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) } }