All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- performance optimization: updateLayout is only called for components affected by navigation
- onEnterRelease event triggered when the Enter is released from the focused item
- SSR support, additional checks for
windowobject to avoid errors on SSR environments.
- Added
updateAllSpatialLayoutsto allow updating components layout at any time that is required.
- Added
blockNavigationOutto avoid focus out from the selected component.
- Fixed issue where this library didn't work in SSR environments due to references to DOM-only variables
- Fixed few issues with referencing non-existing APIs in React Native environments
- added
throttleKeypressesto prevent canceling of throttled events for individual key presses
- update layouts at the beginning of smartNavigate instead of after setFocus
- Fixed regression with using
autoRestoreFocuson components that are focused + getting unmounted and don't have parent
- added
autoRestoreFocusprop to control whether parent component should restore focus on any available child when a currently focused child component is unmounted.
onBecameBlurredandonBecameFocusedare always invoked synchonously with focus change and not on componentDidUpdate
setFocusandnavigateByDirectionaccept an details object, this object is passed back ononBecameBlurredandonBecameFocusedcallbacks
- Changed behaviour of
onBecameFocused, now it's invoked also in case of stealFocus
- Added
onBecameBlurredwith the same behaviour ofonBecameFocusedbut invoked on component losing focus
- Added
KeyDetailsparam on callback functionsonEnterPressandonArrowPress
- Fixed issue #46 Focus jumps on wrong component: Removed
setTimeoutinmeasureLayoutto avoid coordinates mismatches with DOM nodes.
- Added a testing library (
Jest). - Added a private function
getNearestChildthat helps to find the nearest child by coordinates. - Added a unit test of
getNearestChild.
- Removed old logic of finding the nearest child by coordinates of
getNextFocusKeymethod (We use thegetNearestChildfunction instead).
- Added smart focusing by direction (left, right, top, down), if you can't use buttons or focusing by key. Use
navigateByDirectionmethod for it.
- Fixed useless
logIndexupdate.
- Fixed missing reference to a component in native mode
- Added guard checks for Enter press and Arrow press to check whether component exists
- Added a copy of "node" ref to "layout" to also have it onBecameFocused callback
distfolder is removed from source. It is generated only when publishing to NPM now.
- Allowed components to be focused with
setFocuseven if they havefocusable={false}
focusableprop that enables component as a focusable target. Default is true. Usable when you need to temporarily disable focusable behaviour on the component. E.g. disabled button state.
- Moved
reactandreact-domto peer dependencies
- Key up triggers
.cancel()instead of.flush()
- Throttling now applies options to disable trailing functions
- Throttling is now only applied if the throttle option supplied was greater than 0
- Key up now flushes any throttled input
- added support for
onArrowPressproperty, it enables to add a custom behavior when arrows are pressed and can prevent the default navigation.
- Fixed an issue where the
lastFocusedChildKeywere not saved for all focusable parents when focus is jumping to another tree branch withsetFocus.
- Added throttle property to throttle the function fired by the event listener.
- Added support for Native environment. Now if the service is initialized with
nativeModeflag, it will skip creating window event listeners, measuring coordinates and other web-only features. It will still continue to register all focusable components and updatefocusedflag on them. - Added new method
stealFocustowithFocusablehoc. It works exactly the same assetFocusapart from that it doesn't care about arguments passed to this method. This is useful when binding it to a callback that passed some params back that you don't care about.
- Improved the main navigation algorithm. Instead of calculating distance between center of the borders between 2 items in the direction of navigation, the new algorithm now prioritises the distance by the main coordinate and then takes into account the distance by the secondary coordinate. Inspired by this algorithm
- Removed
propagateFocusconfig option and prop forwithFocusableHOC because it was always used for items with children items anyway
- Added more docs regarding preemptive
setFocuson non-existent components - Added
preferredChildFocusKeyproperty to set focus on a specific component during focus propagation
- Save parent
lastFocusedChildKeywhen a new component is focused
This release has few versions combined from v2.0.2.
- Implicit logic for setting focus to own focus key if target focus key component doesn't exist
- Optimized
onUpdateHasFocusChildcallback forwithFocusableHOC. It is called only on components withtrackChildrenprop or config setting now - Updated docs to reflect the publishing to NPM
- Published NPM package
- Orphan DOM nodes problem
- Added Debug and Visual debug modes
- Changed the way of how the sibling components are filtered in
smartNavigatemethod.
- Added Documentation
- Added this Changelog
- Refactored the way how the system stores the current focus key and updates changed components. Before it was stored in Context which caused performance bottleneck when each component got updated to compare Context current focus key with the each component's focus key. Now it is stored only in Spatial Navigation service and only 2 components are updated by directly calling state handlers on them.
- Removed Context
Changelog not maintained.