Permalink
Browse files

Listen to 'input' events in Typeahead for text input changes that don…

…'t fire

'keydown' events

Summary:
CJK input completition (such as selecting the Kanji representation from the
corresponding Romaji in Japanese) changes the input field value, but doesn't
fire a keydown event.

To fix this, we listen to the 'input' event as well. Since we use Javelin for
event delegation, we won't get JS fatals due to the guards in JX.enableDispatch
and listening to events that are never fired is safe. Since we're still
listening to keydown events anyways, we should be fine if the 'input' event
isn't supported.

This might also fix auto-correct in text inputs, since auto-correct might not
fire a keydown event.

Test Plan:
Tested in Chrome and iOS Safari on Facebook's mobile typeahead
Typed 'Keito' using the Romaji keyboard - noted results
Selected the first Kanji approximation of 'Keito' - results changed to reflect
selected Kanji

Reviewers: jg, yungsters, tomo, leebyron

Reviewed By: leebyron

CC: aran, leebyron

Differential Revision: 1057
  • Loading branch information...
1 parent 6501213 commit 7534a0237560bc37446e033c7d82a205fb999f19 Jeffrey Lin committed Oct 27, 2011
Showing with 2 additions and 1 deletion.
  1. +1 −0 src/core/init.js
  2. +1 −1 src/lib/control/typeahead/Typeahead.js
View
1 src/core/init.js
@@ -132,6 +132,7 @@
'mouseup',
'keyup',
'keydown',
+ 'input',
'drop',
'dragenter',
'dragleave',
View
2 src/lib/control/typeahead/Typeahead.js
@@ -70,7 +70,7 @@ JX.install('Typeahead', {
this._listener = JX.DOM.listen(
this._control,
- ['focus', 'blur', 'keypress', 'keydown'],
+ ['focus', 'blur', 'keypress', 'keydown', 'input'],
null,
JX.bind(this, this.handleEvent));

0 comments on commit 7534a02

Please sign in to comment.