Clear hidden input compositionstart on Chrome 56

We use the value of the hidden input to display a preview of the
composition, but it might already contain spaces from previous
keystrokes, since we don't call preventDefault when spaces are inserted.
This commit is contained in:
Nathan Sobo
2017-08-11 15:57:46 -06:00
parent 8667cfdd13
commit 54a6f0d29f

View File

@@ -1644,6 +1644,10 @@ class TextEditorComponent {
// 4. compositionend fired
// 5. textInput fired; event.data == the completion string
didCompositionStart () {
if (parseInt(process.versions.chrome) === 56) {
this.getHiddenInput().value = ''
}
this.compositionCheckpoint = this.props.model.createCheckpoint()
if (this.accentedCharacterMenuIsOpen) {
this.props.model.selectLeft()
@@ -1653,7 +1657,7 @@ class TextEditorComponent {
didCompositionUpdate (event) {
if (parseInt(process.versions.chrome) === 56) {
process.nextTick(() => {
const previewText = this.refs.cursorsAndInput.refs.hiddenInput.value
const previewText = this.getHiddenInput().value
this.props.model.insertText(previewText, {select: true})
})
} else {
@@ -2815,6 +2819,10 @@ class TextEditorComponent {
return this.props.inputEnabled != null ? this.props.inputEnabled : true
}
getHiddenInput () {
return this.refs.cursorsAndInput.refs.hiddenInput
}
getPlatform () {
return this.props.platform || process.platform
}