@@ -569,7 +569,9 @@ class SpatialNavigation {
569569 this . log ( 'smartNavigate' , 'this.focusKey' , this . focusKey ) ;
570570
571571 if ( ! this . nativeMode && ! fromParentFocusKey ) {
572- this . updateAllLayouts ( ) ;
572+ forOwn ( this . focusableComponents , ( component ) => {
573+ component . layoutUpdated = false ;
574+ } ) ;
573575 }
574576
575577 const currentComponent = this . focusableComponents [ fromParentFocusKey || this . focusKey ] ;
@@ -581,6 +583,7 @@ class SpatialNavigation {
581583 ) ;
582584
583585 if ( currentComponent ) {
586+ this . updateLayout ( currentComponent . focusKey ) ;
584587 const { parentFocusKey, focusKey, layout} = currentComponent ;
585588
586589 const isVerticalDirection = direction === DIRECTION_DOWN || direction === DIRECTION_UP ;
@@ -598,6 +601,7 @@ class SpatialNavigation {
598601 */
599602 const siblings = filter ( this . focusableComponents , ( component ) => {
600603 if ( component . parentFocusKey === parentFocusKey && component . focusable ) {
604+ this . updateLayout ( component . focusKey ) ;
601605 const siblingCutoffCoordinate = SpatialNavigation . getCutoffCoordinate (
602606 isVerticalDirection ,
603607 isIncrementalDirection ,
@@ -726,6 +730,7 @@ class SpatialNavigation {
726730 /**
727731 * Otherwise, trying to focus something by coordinates
728732 */
733+ children . forEach ( ( component ) => this . updateLayout ( component . focusKey ) ) ;
729734 const { focusKey : childKey } = getChildClosestToOrigin ( children ) ;
730735
731736 this . log ( 'getNextFocusKey' , 'childKey will be focused' , childKey ) ;
@@ -790,7 +795,8 @@ class SpatialNavigation {
790795 * E.g. used in native environments to lazy-measure the layout on focus
791796 */
792797 node
793- }
798+ } ,
799+ layoutUpdated : false
794800 } ;
795801
796802 if ( this . nativeMode ) {
@@ -841,6 +847,8 @@ class SpatialNavigation {
841847 const component = this . focusableComponents [ focusKey ] ;
842848
843849 if ( component ) {
850+ this . updateLayout ( component . focusKey ) ;
851+
844852 return component . layout ;
845853 }
846854
@@ -1002,7 +1010,7 @@ class SpatialNavigation {
10021010 updateLayout ( focusKey ) {
10031011 const component = this . focusableComponents [ focusKey ] ;
10041012
1005- if ( ! component || this . nativeMode ) {
1013+ if ( ! component || this . nativeMode || component . layoutUpdated ) {
10061014 return ;
10071015 }
10081016
0 commit comments