mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-23 15:32:59 +02:00
Unset isComposing on keydown with isCompsing false (#4979)
This commit is contained in:
5
.changeset/breezy-lizards-impress.md
Normal file
5
.changeset/breezy-lizards-impress.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Unset isComposing on keydown with isCompsing false
|
@@ -1090,15 +1090,25 @@ export const Editable = (props: EditableProps) => {
|
|||||||
)}
|
)}
|
||||||
onKeyDown={useCallback(
|
onKeyDown={useCallback(
|
||||||
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||||
if (
|
if (!readOnly && hasEditableTarget(editor, event.target)) {
|
||||||
!readOnly &&
|
|
||||||
hasEditableTarget(editor, event.target) &&
|
|
||||||
!isEventHandled(event, attributes.onKeyDown) &&
|
|
||||||
!state.isComposing
|
|
||||||
) {
|
|
||||||
const { nativeEvent } = event
|
const { nativeEvent } = event
|
||||||
const { selection } = editor
|
|
||||||
|
|
||||||
|
// COMPAT: The composition end event isn't fired reliably in all browsers,
|
||||||
|
// so we sometimes might end up stuck in a composition state even though we
|
||||||
|
// aren't composing any more.
|
||||||
|
if (state.isComposing && nativeEvent.isComposing === false) {
|
||||||
|
state.isComposing = false
|
||||||
|
setIsComposing(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
isEventHandled(event, attributes.onKeyDown) ||
|
||||||
|
state.isComposing
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const { selection } = editor
|
||||||
const element =
|
const element =
|
||||||
editor.children[
|
editor.children[
|
||||||
selection !== null ? selection.focus.path[0] : 0
|
selection !== null ? selection.focus.path[0] : 0
|
||||||
|
Reference in New Issue
Block a user