@samitouri / QOS-React / commits / f71455fb31

Fire onBeforeUpdate for space on Android

We deliberately skip the event, but Android Chrome doesn't fire the keypress, so this is wrong.

Josh Duck committed Aug 6, 2014 at 16:33 UTC f71455fb319d1daf5a04cc03357fcd185d9f72ec
1 file changed +8 -3
src/browser/eventPlugins/BeforeInputEventPlugin.js
+8 -3
@@ -69,6 +69,9 @@ var eventTypes = {
69 // Track characters inserted via keypress and composition events.
70 var fallbackChars = null;
71
72 +// Track whether we've ever handled a keypress on the space key.
73 +var hasSpaceKeypress = false;
74 +
75 /**
76 * Return whether a native keypress event is assumed to be a command.
77 * This is required because Firefox fires `keypress` events for key commands
@@ -138,7 +141,8 @@ var BeforeInputEventPlugin = {
141 return;
142 }
143
141 - chars = String.fromCharCode(which);
144 + hasSpaceKeypress = true;
145 + chars = SPACEBAR_CHAR;
146 break;
147
148 case topLevelTypes.topTextInput:
@@ -146,8 +150,9 @@ var BeforeInputEventPlugin = {
150 chars = nativeEvent.data;
151
152 // If it's a spacebar character, assume that we have already handled
149 - // it at the keypress level and bail immediately.
150 - if (chars === SPACEBAR_CHAR) {
153 + // it at the keypress level and bail immediately. Android Chrome
154 + // doesn't give us keycodes, so we need to blacklist it.
155 + if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
156 return;
157 }
158