WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 747ebfd

Browse files
authored
Fix IME crash on iOS, but break capitalisation on iOS (#5877)
* Revert "Make capitalizing work for iOS (#5654)" This reverts commit 2a8b4e9. * Add changeset * Reference the older issue in comment
1 parent 11b957a commit 747ebfd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.changeset/orange-ears-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'slate-react': patch
3+
---
4+
5+
Fix a crash on iOS when composing text using an IME at the start of a block, at the cost of breaking capitalization on iOS in an empty editor.

packages/slate-react/src/components/string.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Editor, Text, Path, Element, Node } from 'slate'
33

44
import { ReactEditor, useSlateStatic } from '..'
55
import { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'
6-
import { IS_ANDROID, IS_IOS } from 'slate-dom'
6+
import { IS_ANDROID } from 'slate-dom'
77
import { MARK_PLACEHOLDER_SYMBOL } from 'slate-dom'
88

99
/**
@@ -127,9 +127,17 @@ export const ZeroWidthString = (props: {
127127
attributes['data-slate-mark-placeholder'] = true
128128
}
129129

130+
// FIXME: Inserting the \uFEFF on iOS breaks capitalization at the start of an
131+
// empty editor (https://github.com/ianstormtaylor/slate/issues/5199).
132+
//
133+
// However, not inserting the \uFEFF on iOS causes the editor to crash when
134+
// inserting any text using an IME at the start of a block. This appears to
135+
// be because accepting an IME suggestion when at the start of a block (no
136+
// preceding \uFEFF) removes one or more DOM elements that `toSlateRange`
137+
// depends on. (https://github.com/ianstormtaylor/slate/issues/5703)
130138
return (
131139
<span {...attributes}>
132-
{!(IS_ANDROID || IS_IOS) || !isLineBreak ? '\uFEFF' : null}
140+
{!IS_ANDROID || !isLineBreak ? '\uFEFF' : null}
133141
{isLineBreak ? <br /> : null}
134142
</span>
135143
)

0 commit comments

Comments
 (0)