From a96f924c49faf7458b3ef8d773449aff1ea56b17 Mon Sep 17 00:00:00 2001 From: Guillermo Constantino Date: Mon, 1 Feb 2021 13:52:29 +0100 Subject: [PATCH] Exposed updateAllSpatialLayouts (#81) * Exposed updateAllSpatialLayouts * typo --- CHANGELOG.md | 4 ++++ README.md | 3 +++ package-lock.json | 2 +- package.json | 2 +- src/spatialNavigation.js | 1 + src/withFocusable.js | 3 ++- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54ed58e..9a55e29 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.6] +### Added +- Added `updateAllSpatialLayouts` to allow updating components layout at any time that is required. + ## [2.12.5] ### Added - Added `blockNavigationOut` to avoid focus out from the selected component. diff --git a/README.md b/README.md index 0a32df2..c234be2 100644 --- a/README.md +++ b/README.md @@ -420,6 +420,9 @@ This function pauses key listeners. Useful when you need to temporary disable na ### `resumeSpatialNavigation`: function This function resumes key listeners if it was paused with [pauseSpatialNavigation](#pauseSpatialNavigation-function) +### `updateAllSpatialLayouts`: function +This function update all components layouts. It can be used before setFocus is invoked, when the layouts have changed without being noticed by spatialNavigation service. + ### Data Types ### `KeyDetails`: object diff --git a/package-lock.json b/package-lock.json index 030c5aa..74cc3f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@noriginmedia/react-spatial-navigation", - "version": "2.12.4", + "version": "2.12.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4e729b9..3c38492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@noriginmedia/react-spatial-navigation", - "version": "2.12.5", + "version": "2.12.6", "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 e7ea191..bfd3cd7 100644 --- a/src/spatialNavigation.js +++ b/src/spatialNavigation.js @@ -309,6 +309,7 @@ class SpatialNavigation { this.pause = this.pause.bind(this); this.resume = this.resume.bind(this); this.setFocus = this.setFocus.bind(this); + this.updateAllLayouts = this.updateAllLayouts.bind(this); this.navigateByDirection = this.navigateByDirection.bind(this); this.init = this.init.bind(this); this.setKeyMap = this.setKeyMap.bind(this); diff --git a/src/withFocusable.js b/src/withFocusable.js index bc93f93..4660cc2 100644 --- a/src/withFocusable.js +++ b/src/withFocusable.js @@ -94,7 +94,8 @@ const withFocusable = ({ onBecameBlurred(layout, rest, details); }, pauseSpatialNavigation: () => SpatialNavigation.pause, - resumeSpatialNavigation: () => SpatialNavigation.resume + resumeSpatialNavigation: () => SpatialNavigation.resume, + updateAllSpatialLayouts: () => SpatialNavigation.updateAllLayouts }), lifecycle({