@joewinke/jatui 0.18.0 → 0.18.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/dist/actions/listNav.d.ts +6 -0
- package/dist/actions/listNav.js +25 -0
- package/package.json +1 -1
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
* select, contenteditable) and most modifier combos are skipped so the
|
|
7
7
|
* shortcuts never interfere with typing or app-level keybindings.
|
|
8
8
|
*
|
|
9
|
+
* Focus honesty (mos-5lzns.59): Enter/Space only select the j/k cursor's
|
|
10
|
+
* item when real DOM focus is not on a different activatable control
|
|
11
|
+
* (a link/button/summary/[role=button]). After Tab moves focus elsewhere,
|
|
12
|
+
* Enter activates that control and Space keeps its native meaning instead
|
|
13
|
+
* of triggering the highlighted item.
|
|
14
|
+
*
|
|
9
15
|
* Vim-motion layer (always on):
|
|
10
16
|
*
|
|
11
17
|
* gg jump to first item
|
package/dist/actions/listNav.js
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
* select, contenteditable) and most modifier combos are skipped so the
|
|
7
7
|
* shortcuts never interfere with typing or app-level keybindings.
|
|
8
8
|
*
|
|
9
|
+
* Focus honesty (mos-5lzns.59): Enter/Space only select the j/k cursor's
|
|
10
|
+
* item when real DOM focus is not on a different activatable control
|
|
11
|
+
* (a link/button/summary/[role=button]). After Tab moves focus elsewhere,
|
|
12
|
+
* Enter activates that control and Space keeps its native meaning instead
|
|
13
|
+
* of triggering the highlighted item.
|
|
14
|
+
*
|
|
9
15
|
* Vim-motion layer (always on):
|
|
10
16
|
*
|
|
11
17
|
* gg jump to first item
|
|
@@ -75,6 +81,18 @@ function isTypingTarget(target) {
|
|
|
75
81
|
return true;
|
|
76
82
|
return target.isContentEditable;
|
|
77
83
|
}
|
|
84
|
+
/** Controls that own Enter/Space by real DOM focus. When one of these holds
|
|
85
|
+
* focus (and it is not the focused list item itself), listNav must not
|
|
86
|
+
* consume the key — the browser default (follow the link, press the
|
|
87
|
+
* button, toggle the disclosure) or the page's own handler wins. */
|
|
88
|
+
const ACTIVATABLE_SELECTOR = 'a[href], button, summary, [role="button"]';
|
|
89
|
+
function isActivatable(target) {
|
|
90
|
+
if (typeof HTMLElement === 'undefined')
|
|
91
|
+
return false;
|
|
92
|
+
if (!(target instanceof HTMLElement))
|
|
93
|
+
return false;
|
|
94
|
+
return target.matches(ACTIVATABLE_SELECTOR);
|
|
95
|
+
}
|
|
78
96
|
function hasModifier(e) {
|
|
79
97
|
return e.ctrlKey || e.metaKey || e.altKey;
|
|
80
98
|
}
|
|
@@ -497,6 +515,13 @@ function makeController(optsRef) {
|
|
|
497
515
|
const el = items[focused];
|
|
498
516
|
if (!el)
|
|
499
517
|
return false;
|
|
518
|
+
// Focus honesty (mos-5lzns.59): when real DOM focus sits on a
|
|
519
|
+
// different activatable control (the user Tabbed away from the
|
|
520
|
+
// list), Enter/Space belongs to that control — Enter must follow
|
|
521
|
+
// the link / press the button, and Space must keep scrolling.
|
|
522
|
+
// Bail without consuming the event.
|
|
523
|
+
if (e.target !== el && isActivatable(e.target))
|
|
524
|
+
return false;
|
|
500
525
|
e.preventDefault();
|
|
501
526
|
clearPending();
|
|
502
527
|
opts.onSelect?.(el, focused);
|