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

fix macos accent menu when using arrow keys (#5046)

This commit is contained in:
Eric Meier
2022-07-15 15:12:48 +02:00
committed by GitHub
parent 0b2e6c79c0
commit f96b659755
2 changed files with 20 additions and 7 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
fix macos accent menu when using arrow keys

View File

@@ -340,12 +340,12 @@ export const Editable = (props: EditableProps) => {
const { inputType: type } = event const { inputType: type } = event
const data = (event as any).dataTransfer || event.data || undefined const data = (event as any).dataTransfer || event.data || undefined
// These two types occur while a user is composing text and can't be const isCompositionChange =
// cancelled. Let them through and wait for the composition to end. type === 'insertCompositionText' || type === 'deleteCompositionText'
if (
type === 'insertCompositionText' || // COMPAT: use composition change events as a hint to where we should insert
type === 'deleteCompositionText' // composition text if we aren't composing to work around https://github.com/ianstormtaylor/slate/issues/5038
) { if (isCompositionChange && ReactEditor.isComposing(editor)) {
return return
} }
@@ -431,7 +431,9 @@ export const Editable = (props: EditableProps) => {
native = false native = false
const selectionRef = const selectionRef =
editor.selection && Editor.rangeRef(editor, editor.selection) !isCompositionChange &&
editor.selection &&
Editor.rangeRef(editor, editor.selection)
Transforms.select(editor, range) Transforms.select(editor, range)
@@ -442,6 +444,12 @@ export const Editable = (props: EditableProps) => {
} }
} }
// Composition change types occur while a user is composing text and can't be
// cancelled. Let them through and wait for the composition to end.
if (isCompositionChange) {
return
}
if (!native) { if (!native) {
event.preventDefault() event.preventDefault()
} }