@noriginmedia/react-spatial-navigation
Advanced tools
Comparing version 2.11.0 to 2.12.0
@@ -7,2 +7,6 @@ # Changelog | ||
## [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. | ||
## [2.11.0] | ||
@@ -9,0 +13,0 @@ ### Changed |
@@ -786,2 +786,3 @@ 'use strict'; | ||
preferredChildFocusKey = _ref3.preferredChildFocusKey, | ||
autoRestoreFocus = _ref3.autoRestoreFocus, | ||
focusable = _ref3.focusable; | ||
@@ -804,2 +805,3 @@ | ||
focusable: focusable, | ||
autoRestoreFocus: autoRestoreFocus, | ||
layout: { | ||
@@ -862,3 +864,3 @@ x: 0, | ||
*/ | ||
if (isFocused) { | ||
if (isFocused && parentComponent.autoRestoreFocus) { | ||
this.setFocus(parentFocusKey); | ||
@@ -865,0 +867,0 @@ } |
@@ -77,3 +77,4 @@ 'use strict'; | ||
_ref$trackChildren = _ref.trackChildren, | ||
configTrackChildren = _ref$trackChildren === undefined ? false : _ref$trackChildren; | ||
configTrackChildren = _ref$trackChildren === undefined ? false : _ref$trackChildren, | ||
configAutoRestoreFocus = _ref.autoRestoreFocus; | ||
@@ -199,3 +200,5 @@ return (0, _compose2.default)((0, _getContext2.default)({ | ||
_props$focusable = _props.focusable, | ||
focusable = _props$focusable === undefined ? true : _props$focusable; | ||
focusable = _props$focusable === undefined ? true : _props$focusable, | ||
_props$autoRestoreFoc = _props.autoRestoreFocus, | ||
autoRestoreFocus = _props$autoRestoreFoc === undefined ? true : _props$autoRestoreFoc; | ||
@@ -218,2 +221,3 @@ | ||
trackChildren: configTrackChildren || trackChildren, | ||
autoRestoreFocus: configAutoRestoreFocus !== undefined ? configAutoRestoreFocus : autoRestoreFocus, | ||
focusable: focusable | ||
@@ -246,5 +250,5 @@ }); | ||
} | ||
}), _pure2.default, omitProps(['onBecameFocusedHandler', 'onBecameBlurredHandler', 'onEnterPressHandler', 'onArrowPressHandler', 'onUpdateFocus', 'onUpdateHasFocusedChild', 'forgetLastFocusedChild', 'trackChildren'])); | ||
}), _pure2.default, omitProps(['onBecameFocusedHandler', 'onBecameBlurredHandler', 'onEnterPressHandler', 'onArrowPressHandler', 'onUpdateFocus', 'onUpdateHasFocusedChild', 'forgetLastFocusedChild', 'trackChildren', 'autoRestoreFocus'])); | ||
}; | ||
exports.default = withFocusable; |
{ | ||
"name": "@noriginmedia/react-spatial-navigation", | ||
"version": "2.11.0", | ||
"version": "2.12.0", | ||
"description": "HOC-based Spatial Navigation (key navigation) solution for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -90,2 +90,3 @@ # react-spatial-navigation | ||
onBecameBlurred={props.onItemBlurred} | ||
autoRestoreFocus={false} | ||
/> | ||
@@ -240,2 +241,7 @@ ... | ||
##### `autoRestoreFocus`: boolean | ||
To determine whether parent component should focus the first available child component when currently focused child is unmounted. | ||
* **true (default)** | ||
* **false** | ||
## Props that can be applied to HOC | ||
@@ -250,2 +256,5 @@ All these props are optional. | ||
### `autoRestoreFocus`: boolean | ||
Same as in [config](#config). | ||
### `focusable`: boolean | ||
@@ -252,0 +261,0 @@ Determine whether this component should be focusable (in other words, whether it's *currently* participating in the spatial navigation tree). This allows a focusable component to be ignored as a navigation target despite being mounted (e.g. due to being off-screen, hidden, or temporarily disabled). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103711
1839
466