Releases: NoriginMedia/Norigin-Spatial-Navigation
Releases · NoriginMedia/Norigin-Spatial-Navigation
Dynamic RTL Support and Custom Distance Calculation Enhancements
[2.2.1]
Added
- New init config option
distanceCalculationMethod
that allows switching between edge-based, center-based and corner-based (default) distance calculations. - Support for a custom distance calculation function via the
customDistanceCalculationFunction
option, enabling custom logic for determining distances between focusable components. This will override thegetSecondaryAxisDistance
method. - Added
updateRTL
method to update the RTL behavior dynamically. This method allows toggling the Right-to-Left layout at runtime, updating the spatial navigation behavior without requiring reinitialization.
domNodeFocusOptions support
Added
- new
init
config optiondomNodeFocusOptions
for passing FocusOptions when usingshouldFocusDOMNode
RTL support, native events support
Added
- new
init
config optionshouldUseNativeEvents
that enables the use of native events for triggering actions, such as clicks or key presses. - new
init
config optionrtl
that changes focus behavior for layouts in right-to-left (RTL) languages such as Arabic and Hebrew.
Console warn on empty ref, support for strings for Key Event names
[2.0.2]
Added
- Console warning when passing an empty
ref
touseFocusable
- Support for string names for Key Events. Now you can configure the key map with numbers or event names like
ArrowRight
.
Restoring focus to the parent with `preferredChildFocusKey` set
[2.0.1]
Fixed
- Restoring focus to the parent with
preferredChildFocusKey
set
Moved global methods, new features for focus restore and boundary directions
Added
- New property for
useFocusable
-focusBoundaryDirections
, array of directions to block whenisFocusBoundary
is enabled - New property
useFocusable
-forceFocus
to mark the component to be the target for auto-restore focus logic when focus is lost - New global method
doesFocusableExist
to check if the focusable component exists before setting focus on it. Safety feature
Changed
- [BREAKING] Top level exports
setFocus, getCurrentFocusKey, navigateByDirection, pause, resume, updateAllLayouts
are now exported fromSpatialNavigation
instead ofuseFocusable
hook.
Fixed
- Context display name is now called
FocusContext
in React Devtools - Updating
lastFocusedChildKey
for newly added parent components
Bugfixes, auto restore focus improvements
- Fixed the issue where component would have kept itself in the array of
parentsHavingFocusedChild
array after removal - Further improvements to
autoRestoreFocus
logic to trigger not only on Lead components, but also on Parents that had focused child when being removed. Edge case, normally children are removed first.
Bugfixes
Fixed
- Fixed a bug where parents were not updating their
hasFocusedChild
when new child is created and focused right away - Fixed a bug where
lastFocusedChild
was updated only on blur, but not on manual focus, resulting in a wrong key being stored
Changed
- Renamed
useFocusedContext
file touseFocusContext
to match the export name
Handling `StrictMode` without custom hook, more debug logs
Added
- Extra debug logs, printing focusable components data in addition to DOM nodes.
- Extra call to set
focused
state tofalse
on unmount. This is to support "double-mount" in Strict mode in React 18.
Changed
- [Potentially Breaking] Auto restore focus when the item is removed is now happening with a slight debounced delay. This is done to prevent multiple automatic focus restorations when multiple elements are remove one by one. Now it will accumulate all the auto-restore focus calls into one delayed debounced call with the final target parent to get focused.
Removed
- Custom
useEffectOnce
hook that introduced issues with unmounted components being remained as focusable.
Accessibility support: `.focus()` DOM node when the item is focused
This release includes support for Accessibility. With the new configuration flag shouldFocusDOMNode
it is possible to also set a native browser focus on the DOM node when the item is focused by the library. This allows usage of aria
tags for screen readers.