@solidtv/solid 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -460,7 +460,8 @@ const propagateKeyPress = (
460
460
  const eventHandler = elm[eventHandlerKey];
461
461
  if (isFunction(eventHandler)) {
462
462
  lastHandlerSeen = elm;
463
- handled = eventHandler.call(elm, e, elm, finalFocusElm) === true;
463
+ handled =
464
+ eventHandler.call(elm, e, elm, finalFocusElm, mappedEvent) === true;
464
465
  }
465
466
  }
466
467
  if (!handled && !isUp) {
@@ -218,10 +218,20 @@ export function handleNavigation(
218
218
  * >
219
219
  * ```
220
220
  */
221
- export const navigableHandleNavigation: lng.KeyHandler = function (e) {
221
+ export const navigableHandleNavigation: lng.KeyHandler = function (
222
+ e,
223
+ _target,
224
+ _handlerElm,
225
+ mappedEvent,
226
+ ) {
227
+ // The key map's name for the key, so that a key mapped to a direction
228
+ // under another name (an Xbox D-pad's GamepadDPadLeft) moves that way.
229
+ const key = mappedEvent || e.key;
222
230
  return moveSelection(
223
231
  this as lngp.NavigableElement,
224
- e.key === 'ArrowUp' || e.key === 'ArrowLeft' ? -1 : 1,
232
+ key === 'Up' || key === 'Left' || key === 'ArrowUp' || key === 'ArrowLeft'
233
+ ? -1
234
+ : 1,
225
235
  );
226
236
  };
227
237
 
@@ -345,7 +355,12 @@ export const spatialForwardFocus: lng.ForwardFocusHandler = function () {
345
355
  * >
346
356
  * ```
347
357
  */
348
- export const spatialHandleNavigation: lng.KeyHandler = function (e) {
358
+ export const spatialHandleNavigation: lng.KeyHandler = function (
359
+ e,
360
+ _target,
361
+ _handlerElm,
362
+ mappedEvent,
363
+ ) {
349
364
  let selected = this.selected;
350
365
 
351
366
  if (typeof selected !== 'number' || !idxInArray(selected, this.children)) {
@@ -356,16 +371,22 @@ export const spatialHandleNavigation: lng.KeyHandler = function (e) {
356
371
  const prevChild = this.children[selected]!;
357
372
 
358
373
  const move = { x: 0, y: 0 };
359
- switch (e.key) {
374
+ // The key map's name for the key, so that a key mapped to a direction
375
+ // under another name (an Xbox D-pad's GamepadDPadRight) is recognised.
376
+ switch (mappedEvent || e.key) {
377
+ case 'Left':
360
378
  case 'ArrowLeft':
361
379
  move.x = -1;
362
380
  break;
381
+ case 'Right':
363
382
  case 'ArrowRight':
364
383
  move.x = 1;
365
384
  break;
385
+ case 'Up':
366
386
  case 'ArrowUp':
367
387
  move.y = -1;
368
388
  break;
389
+ case 'Down':
369
390
  case 'ArrowDown':
370
391
  move.y = 1;
371
392
  break;