Skip to content

Commit

Permalink
Fire onBeforeUpdate for space on Android
Browse files Browse the repository at this point in the history
We deliberately skip the event, but Android Chrome
doesn't fire the keypress, so this is wrong.
  • Loading branch information
joshduck authored and zpao committed Aug 6, 2014
1 parent 036d751 commit f71455f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/browser/eventPlugins/BeforeInputEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -138,16 +141,18 @@ var BeforeInputEventPlugin = {
return;
}

chars = String.fromCharCode(which);
hasSpaceKeypress = true;
chars = SPACEBAR_CHAR;
break;

case topLevelTypes.topTextInput:
// Record the characters to be added to the DOM.
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;
}

Expand Down

0 comments on commit f71455f

Please sign in to comment.