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.
- Added
KeyDetails
param on callback functionsonEnterPress
andonArrowPress
- Fixed issue #46 Focus jumps on wrong component: Removed
setTimeout
inmeasureLayout
to avoid coordinates mismatches with DOM nodes.
- Added a testing library (
Jest
). - Added a private function
getNearestChild
that 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
getNextFocusKey
method (We use thegetNearestChild
function instead).
- Added smart focusing by direction (left, right, top, down), if you can't use buttons or focusing by key. Use
navigateByDirection
method for it.
- Fixed useless
logIndex
update.
- 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
dist
folder is removed from source. It is generated only when publishing to NPM now.
- Allowed components to be focused with
setFocus
even if they havefocusable={false}
focusable
prop 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
react
andreact-dom
to 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
onArrowPress
property, it enables to add a custom behavior when arrows are pressed and can prevent the default navigation.
- Fixed an issue where the
lastFocusedChildKey
were 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
nativeMode
flag, it will skip creating window event listeners, measuring coordinates and other web-only features. It will still continue to register all focusable components and updatefocused
flag on them. - Added new method
stealFocus
towithFocusable
hoc. It works exactly the same assetFocus
apart 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
propagateFocus
config option and prop forwithFocusable
HOC because it was always used for items with children items anyway
- Added more docs regarding preemptive
setFocus
on non-existent components - Added
preferredChildFocusKey
property to set focus on a specific component during focus propagation
- Save parent
lastFocusedChildKey
when 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
onUpdateHasFocusChild
callback forwithFocusable
HOC. It is called only on components withtrackChildren
prop 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
smartNavigate
method.
- 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.