mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
TextInputEventPlugin, SyntheticTextInputEvent
This diff introduces `TextInputEventPlugin` and `SyntheticTextInputEvent`, which are based on Webkit's native `textInput` event. In Chrome, Safari, and Opera, the `textInput` event fires prior to the insertion of character data into the document. For normal typing, for example, thevent sequence is: `keydown`, `keypress`, `textInput`, `input`, `keyup`. The `textInput` event contains a `data` field corresponding to the character data that will actually be inserted. There is also a `beforeinput` event described by http://www.w3.org/TR/DOM-Level-3-Events/#event-type-beforeinput, and this is essentially that event, so it may make sense to rename the plugin. This event is especially useful because it solves a number of issues we can't currently handle with only keypress and composition events: - **Windows Chrome: Trailing characters discarded in Korean IME.** For instance, `안녕하세요` becomes `안녕하세` with the final character discarded by the final `compositionend` event. The `textInput` event fires correctly with the final character. - **Windows Chrome: Special characters discarded in IME.** Certain ideographs are discarded in IME mode. In Japanese, typing the ideographic space character is not represented by keypress but //is// represented by the subsequent `textInput`. This issue also applies to punctuation characters in Chinese. - **OSX Chrome: Characters from palette discarded.** Inserting characters from the OSX character palette fails, since no keypress is fired. The plugin is useful for Firefox and IE. For these, we record inserted characters via keypress and compositionend events and dispatch the synthetic event with these characters as the `data` field to match the native `textInput` event. - Firefox has no corresponding `textInput` event and has not yet implemented `beforeinput`. - IE has a native `textinput` event, but it fires after the DOM mutation has already occurred, so it isn't very useful as an analog to the Webkit version. I'm just not going to bother with it.
This commit is contained in:
committed by
Paul O’Shannessy
parent
f10f32aaaf
commit
116ee058eb
@@ -61,6 +61,7 @@ var topLevelTypes = keyMirror({
|
||||
topScroll: null,
|
||||
topSelectionChange: null,
|
||||
topSubmit: null,
|
||||
topTextInput: null,
|
||||
topTouchCancel: null,
|
||||
topTouchEnd: null,
|
||||
topTouchMove: null,
|
||||
|
||||
Reference in New Issue
Block a user