From 8620d4aba1884b74736f7756e573c41fd59d3496 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Mon, 16 Mar 2020 16:24:53 +0100 Subject: [PATCH] Fixed regression with autoRestoreFocus --- CHANGELOG.md | 4 ++++ package-lock.json | 2 +- package.json | 2 +- src/spatialNavigation.js | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 094d654..492184d 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.1] +### Fixed +- Fixed regression with using `autoRestoreFocus` on components that are focused + getting unmounted and don't have parent + ## [2.12.0] ### Added - added `autoRestoreFocus` prop to control whether parent component should restore focus on any available child when a currently focused child component is unmounted. diff --git a/package-lock.json b/package-lock.json index 466a026..97ebefd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@noriginmedia/react-spatial-navigation", - "version": "2.12.0", + "version": "2.12.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3d111f7..45f19cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@noriginmedia/react-spatial-navigation", - "version": "2.12.0", + "version": "2.12.1", "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 b393f44..d3b3749 100644 --- a/src/spatialNavigation.js +++ b/src/spatialNavigation.js @@ -790,7 +790,7 @@ class SpatialNavigation { /** * If the component was also focused at this time, focus another one */ - if (isFocused && parentComponent.autoRestoreFocus) { + if (isFocused && parentComponent && parentComponent.autoRestoreFocus) { this.setFocus(parentFocusKey); } }