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:
5
.changeset/ten-chefs-cheat.md
Normal file
5
.changeset/ten-chefs-cheat.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix macos accent menu when using arrow keys
|
@@ -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()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user