Skip to content

Commit f71455f

Browse files
joshduckzpao
authored andcommitted
Fire onBeforeUpdate for space on Android
We deliberately skip the event, but Android Chrome doesn't fire the keypress, so this is wrong.
1 parent 036d751 commit f71455f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/browser/eventPlugins/BeforeInputEventPlugin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ var eventTypes = {
6969
// Track characters inserted via keypress and composition events.
7070
var fallbackChars = null;
7171

72+
// Track whether we've ever handled a keypress on the space key.
73+
var hasSpaceKeypress = false;
74+
7275
/**
7376
* Return whether a native keypress event is assumed to be a command.
7477
* This is required because Firefox fires `keypress` events for key commands
@@ -138,16 +141,18 @@ var BeforeInputEventPlugin = {
138141
return;
139142
}
140143

141-
chars = String.fromCharCode(which);
144+
hasSpaceKeypress = true;
145+
chars = SPACEBAR_CHAR;
142146
break;
143147

144148
case topLevelTypes.topTextInput:
145149
// Record the characters to be added to the DOM.
146150
chars = nativeEvent.data;
147151

148152
// 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) {
151156
return;
152157
}
153158

0 commit comments

Comments
 (0)