diff --git a/CHANGELOG.md b/CHANGELOG.md index 492184d..041c2e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.12.2] +### Changed +- update layouts at the beginning of smartNavigate instead of after setFocus + ## [2.12.1] ### Fixed - Fixed regression with using `autoRestoreFocus` on components that are focused + getting unmounted and don't have parent diff --git a/package-lock.json b/package-lock.json index 97ebefd..fb994f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@noriginmedia/react-spatial-navigation", - "version": "2.12.1", + "version": "2.12.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 45f19cf..4622975 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@noriginmedia/react-spatial-navigation", - "version": "2.12.1", + "version": "2.12.2", "description": "HOC-based Spatial Navigation (key navigation) solution for React", "main": "dist/index.js", "files": [ diff --git a/src/spatialNavigation.js b/src/spatialNavigation.js index d3b3749..09de9f1 100644 --- a/src/spatialNavigation.js +++ b/src/spatialNavigation.js @@ -537,6 +537,10 @@ class SpatialNavigation { this.log('smartNavigate', 'fromParentFocusKey', fromParentFocusKey); this.log('smartNavigate', 'this.focusKey', this.focusKey); + if (!this.nativeMode && !fromParentFocusKey) { + this.updateAllLayouts(); + } + const currentComponent = this.focusableComponents[fromParentFocusKey || this.focusKey]; this.log( @@ -946,10 +950,6 @@ class SpatialNavigation { this.setCurrentFocusedKey(newFocusKey, details); this.updateParentsHasFocusedChild(newFocusKey, details); this.updateParentsLastFocusedChild(lastFocusedKey); - - if (!this.nativeMode) { - this.updateAllLayouts(); - } } updateAllLayouts() {