Skip to content

Commit 7710c7c

Browse files
committed
Fix bug in input resetting during composition
Closes #6893
1 parent fc0440b commit 7710c7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/input/TextareaInput.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default class TextareaInput {
2828
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
2929
this.hasSelection = false
3030
this.composing = null
31+
this.resetting = false
3132
}
3233

3334
init(display) {
@@ -158,8 +159,9 @@ export default class TextareaInput {
158159
// Reset the input to correspond to the selection (or to be empty,
159160
// when not typing and nothing is selected)
160161
reset(typing) {
161-
if (this.contextMenuPending || this.composing) return
162+
if (this.contextMenuPending || this.composing && typing) return
162163
let cm = this.cm
164+
this.resetting = true
163165
if (cm.somethingSelected()) {
164166
this.prevInput = ""
165167
let content = cm.getSelection()
@@ -170,6 +172,7 @@ export default class TextareaInput {
170172
this.prevInput = this.textarea.value = ""
171173
if (ie && ie_version >= 9) this.hasSelection = null
172174
}
175+
this.resetting = false
173176
}
174177

175178
getField() { return this.textarea }
@@ -227,7 +230,7 @@ export default class TextareaInput {
227230
// possible when it is clear that nothing happened. hasSelection
228231
// will be the case when there is a lot of text in the textarea,
229232
// in which case reading its value would be expensive.
230-
if (this.contextMenuPending || !cm.state.focused ||
233+
if (this.contextMenuPending || this.resetting || !cm.state.focused ||
231234
(hasSelection(input) && !prevInput && !this.composing) ||
232235
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
233236
return false

0 commit comments

Comments
 (0)