Allow successive accented characters to be inserted in React editor

Refs #2732

Because we're only checking the length of the input element's selection
in the React editor on textinput events and not also its content, we
were mistaking some IME compositions as accented character menu
insertions. Clearing the content of the input on 'compositionend'
prevents this issue.
This commit is contained in:
Nathan Sobo
2014-06-25 11:12:16 -06:00
parent 1c69995bb6
commit 63e8099088
2 changed files with 48 additions and 21 deletions

View File

@@ -356,12 +356,13 @@ EditorComponent = React.createClass
# 5. textInput fired; event.data == the completion string
selectedText = null
node.addEventListener 'compositionstart', =>
node.addEventListener 'compositionstart', ->
selectedText = editor.getSelectedText()
node.addEventListener 'compositionupdate', (event) =>
node.addEventListener 'compositionupdate', (event) ->
editor.insertText(event.data, select: true, undo: 'skip')
node.addEventListener 'compositionend', =>
node.addEventListener 'compositionend', (event) ->
editor.insertText(selectedText, select: true, undo: 'skip')
event.target.value = ''
listenForCommands: ->
{parentView, editor, mini} = @props