@@ -414,10 +414,17 @@ function dispatchCancel(
414414 }
415415}
416416
417- function isValidKeyPress ( key : string ) : boolean {
417+ function isValidKeyboardEvent ( nativeEvent : Object ) : boolean {
418+ const { key, target} = nativeEvent ;
419+ const { tagName, isContentEditable} = target ;
418420 // Accessibility for keyboards. Space and Enter only.
419421 // "Spacebar" is for IE 11
420- return key === 'Enter' || key === ' ' || key === 'Spacebar' ;
422+ return (
423+ ( key === 'Enter' || key === ' ' || key === 'Spacebar' ) &&
424+ ( tagName !== 'INPUT' &&
425+ tagName !== 'TEXTAREA' &&
426+ isContentEditable !== true )
427+ ) ;
421428}
422429
423430function calculateDelayMS ( delay : ?number , min = 0 , fallback = 0 ) {
@@ -671,7 +678,7 @@ const PressResponder = {
671678
672679 // Ignore unrelated key events
673680 if ( pointerType === 'keyboard' ) {
674- if ( ! isValidKeyPress ( nativeEvent . key ) ) {
681+ if ( ! isValidKeyboardEvent ( nativeEvent ) ) {
675682 return ;
676683 }
677684 }
@@ -717,7 +724,7 @@ const PressResponder = {
717724 addRootEventTypes ( context , state ) ;
718725 } else {
719726 // Prevent spacebar press from scrolling the window
720- if ( isValidKeyPress ( nativeEvent . key ) && nativeEvent . key === ' ' ) {
727+ if ( isValidKeyboardEvent ( nativeEvent ) && nativeEvent . key === ' ' ) {
721728 nativeEvent . preventDefault ( ) ;
722729 }
723730 }
@@ -859,7 +866,7 @@ const PressResponder = {
859866 // Ignore unrelated keyboard events and verify press is within
860867 // responder region for non-keyboard events.
861868 if ( pointerType === 'keyboard' ) {
862- if ( ! isValidKeyPress ( nativeEvent . key ) ) {
869+ if ( ! isValidKeyboardEvent ( nativeEvent ) ) {
863870 return ;
864871 }
865872 // If the event target isn't within the press target, check if we're still
0 commit comments