@@ -18,8 +18,8 @@ import Position from './Position';
1818import React from 'react' ;
1919import UIManager from '../UIManager' ;
2020import View from '../View' ;
21- import Platform from " ../Platform" ;
22- import TVEventHandler from " ../TVEventHandler" ;
21+ import Platform from ' ../Platform' ;
22+ import TVEventHandler from ' ../TVEventHandler' ;
2323
2424type Event = Object ;
2525type PressEvent = Object ;
@@ -382,7 +382,6 @@ const TouchableMixin = {
382382 } ;
383383 this . _touchableNode . addEventListener ( 'blur' , this . _touchableBlurListener ) ;
384384 }
385-
386385 } ,
387386
388387 /**
@@ -405,9 +404,9 @@ const TouchableMixin = {
405404 * `this.state.touchable`.
406405 */
407406 touchableGetInitialState : function ( ) {
407+ this . _isFocused = false ;
408408 return {
409- touchable : { touchState : undefined , responderID : null } ,
410- focused : false
409+ touchable : { touchState : undefined , responderID : null }
411410 } ;
412411 } ,
413412
@@ -570,7 +569,7 @@ const TouchableMixin = {
570569 * using `Touchable.Mixin.withoutDefaultFocusAndBlur`.
571570 */
572571 touchableHandleFocus : function ( e : Event ) {
573- this . state . focused = true ;
572+ this . _isFocused = true ;
574573 this . props . onFocus && this . props . onFocus ( e ) ;
575574 } ,
576575
@@ -583,7 +582,7 @@ const TouchableMixin = {
583582 * `Touchable.Mixin.withoutDefaultFocusAndBlur`.
584583 */
585584 touchableHandleBlur : function ( e : Event ) {
586- this . state . focused = false ;
585+ this . _isFocused = false ;
587586 this . props . onBlur && this . props . onBlur ( e ) ;
588587 } ,
589588
@@ -879,35 +878,32 @@ const TouchableMixin = {
879878 // delays and longPress)
880879 touchableHandleKeyEvent : function ( e : Event ) {
881880 const { type, key } = e ;
882- if ( Platform . isTV ) {
881+ if ( Platform . isTV ) {
883882 // Get tvEvent
884883 const tvEvent = TVEventHandler . getTVEvent ( e ) ;
885884 // Dispatch 'select' tvEvent to component
886- if ( tvEvent . eventType === 'select' ) {
885+ if ( tvEvent . eventType === 'select' ) {
887886 this . touchableHandlePress ( tvEvent ) ;
888887 }
889888 // Dispatch tvEvent to all listeners
890889 TVEventHandler . dispatchEvent ( tvEvent ) ;
891890 // Handle next focus
892- if ( this . _touchableNode ) {
891+ if ( this . _touchableNode ) {
893892 let nextFocusID = '' ;
894893 // Check nextFocus* properties
895- if ( this . _touchableNode . hasAttribute ( "nextFocusUp" ) && key === 'ArrowUp' ) {
896- nextFocusID = this . _touchableNode . getAttribute ( "nextFocusUp" ) ;
897- }
898- else if ( this . _touchableNode . hasAttribute ( "nextFocusRight" ) && key === 'ArrowRight' ) {
899- nextFocusID = this . _touchableNode . getAttribute ( "nextFocusRight" ) ;
900- }
901- else if ( this . _touchableNode . hasAttribute ( "nextFocusDown" ) && key === 'ArrowDown' ) {
902- nextFocusID = this . _touchableNode . getAttribute ( "nextFocusDown" ) ;
903- }
904- else if ( this . _touchableNode . hasAttribute ( "nextFocusLeft" ) && key === 'ArrowLeft' ) {
905- nextFocusID = this . _touchableNode . getAttribute ( "nextFocusLeft" ) ;
894+ if ( this . _touchableNode . hasAttribute ( 'nextFocusUp' ) && key === 'ArrowUp' ) {
895+ nextFocusID = this . _touchableNode . getAttribute ( 'nextFocusUp' ) ;
896+ } else if ( this . _touchableNode . hasAttribute ( 'nextFocusRight' ) && key === 'ArrowRight' ) {
897+ nextFocusID = this . _touchableNode . getAttribute ( 'nextFocusRight' ) ;
898+ } else if ( this . _touchableNode . hasAttribute ( 'nextFocusDown' ) && key === 'ArrowDown' ) {
899+ nextFocusID = this . _touchableNode . getAttribute ( 'nextFocusDown' ) ;
900+ } else if ( this . _touchableNode . hasAttribute ( 'nextFocusLeft' ) && key === 'ArrowLeft' ) {
901+ nextFocusID = this . _touchableNode . getAttribute ( 'nextFocusLeft' ) ;
906902 }
907- if ( nextFocusID && nextFocusID !== '' ) {
903+ if ( nextFocusID && nextFocusID !== '' ) {
908904 // Get DOM element
909905 const element = document . getElementById ( nextFocusID ) ;
910- if ( element && element . tabIndex >= 0 ) {
906+ if ( element && element . tabIndex >= 0 ) {
911907 // Force focus
912908 element . focus ( ) ;
913909 // Stop event propagation
@@ -916,8 +912,9 @@ const TouchableMixin = {
916912 }
917913 }
918914 // Trigger Hardware Back Press for Back/Escape event keys
919- if ( type === 'keydown' && ( key === 'Back' || key === 'Escape' ) ) {
920- const hwKeyEvent = new CustomEvent ( "hardwareBackPress" , { } ) ;
915+ if ( type === 'keydown' && ( key === 'Back' || key === 'Escape' ) ) {
916+ // eslint-disable-next-line no-undef
917+ const hwKeyEvent = new CustomEvent ( 'hardwareBackPress' , { } ) ;
921918 document . dispatchEvent ( hwKeyEvent ) ;
922919 }
923920 }
0 commit comments