Skip to content

Commit 4a6193c

Browse files
committed
Version bump, changelog, console warn for empty refs/nodes
1 parent ad1fa14 commit 4a6193c

5 files changed

Lines changed: 22 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [2.0.2]
8+
## Added
9+
- Console warning when passing an empty `ref` to `useFocusable`
10+
- Support for string names for Key Events. Now you can configure the key map with numbers or event names like `ArrowRight`.
11+
712
# [2.0.1]
813
## Fixed
914
- Restoring focus to the parent with `preferredChildFocusKey` set

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ Also consider `role` and `aria-label` attributes. But that depends on the applic
261261
The flag is ignored if `nativeMode` is set.
262262

263263
### `setKeyMap`
264-
Method to set custom key codes. I.e. when the device key codes differ from a standard browser arrow key codes.
264+
Method to set custom key codes (numbers) or key event names (strings) [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#non-printable_keys_function_keys). I.e. when the device key codes differ from a standard browser arrow key codes.
265265
```jsx
266266
setKeyMap({
267-
left: 9001,
268-
up: 9002,
269-
right: 9003,
270-
down: 9004,
271-
enter: 9005
267+
left: 9001, // or 'ArrowLeft'
268+
up: 9002, // or 'ArrowUp'
269+
right: 9003, // or 'ArrowRight'
270+
down: 9004, // or 'ArrowDown'
271+
enter: 9005 // or 'Enter'
272272
});
273273
```
274274

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@noriginmedia/norigin-spatial-navigation",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "React hooks based Spatial Navigation solution",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/SpatialNavigation.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,14 @@ class SpatialNavigationService {
12161216
layoutUpdated: false
12171217
};
12181218

1219+
if (!node) {
1220+
// eslint-disable-next-line no-console
1221+
console.warn(
1222+
'Component added without a node reference. This will result in its coordinates being empty and may cause lost focus. Check the "ref" passed to "useFocusable": ',
1223+
this.focusableComponents[focusKey]
1224+
);
1225+
}
1226+
12191227
if (this.nativeMode) {
12201228
return;
12211229
}

0 commit comments

Comments
 (0)