From f71455fb319d1daf5a04cc03357fcd185d9f72ec Mon Sep 17 00:00:00 2001 From: Josh Duck Date: Wed, 6 Aug 2014 16:33:31 -0700 Subject: [PATCH] Fire onBeforeUpdate for space on Android We deliberately skip the event, but Android Chrome doesn't fire the keypress, so this is wrong. --- src/browser/eventPlugins/BeforeInputEventPlugin.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/browser/eventPlugins/BeforeInputEventPlugin.js b/src/browser/eventPlugins/BeforeInputEventPlugin.js index d4248158ac..92dd7372eb 100644 --- a/src/browser/eventPlugins/BeforeInputEventPlugin.js +++ b/src/browser/eventPlugins/BeforeInputEventPlugin.js @@ -69,6 +69,9 @@ var eventTypes = { // Track characters inserted via keypress and composition events. var fallbackChars = null; +// Track whether we've ever handled a keypress on the space key. +var hasSpaceKeypress = false; + /** * Return whether a native keypress event is assumed to be a command. * This is required because Firefox fires `keypress` events for key commands @@ -138,7 +141,8 @@ var BeforeInputEventPlugin = { return; } - chars = String.fromCharCode(which); + hasSpaceKeypress = true; + chars = SPACEBAR_CHAR; break; case topLevelTypes.topTextInput: @@ -146,8 +150,9 @@ var BeforeInputEventPlugin = { chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled - // it at the keypress level and bail immediately. - if (chars === SPACEBAR_CHAR) { + // it at the keypress level and bail immediately. Android Chrome + // doesn't give us keycodes, so we need to blacklist it. + if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { return; }