@react-aria/interactions 3.0.0-nightly.1698 → 3.0.0-nightly.1707
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/main.js +11 -8
- package/dist/main.js.map +1 -1
- package/dist/module.js +11 -8
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/usePress.ts +13 -8
package/dist/main.js
CHANGED
|
@@ -292,7 +292,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
292
292
|
};
|
|
293
293
|
let pressProps = {
|
|
294
294
|
onKeyDown (e) {
|
|
295
|
-
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent) && e.currentTarget.contains(e.target)) {
|
|
295
|
+
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) {
|
|
296
296
|
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
|
|
297
297
|
e.stopPropagation();
|
|
298
298
|
// If the event is repeating, it may have started on a different element
|
|
@@ -306,10 +306,13 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
306
306
|
// instead of the same element where the key down event occurred.
|
|
307
307
|
addGlobalListener(document, 'keyup', onKeyUp, false);
|
|
308
308
|
}
|
|
309
|
-
}
|
|
309
|
+
} else if (e.key === 'Enter' && $0294ea432cd92340$var$isHTMLAnchorLink(e.currentTarget)) // If the target is a link, we won't have handled this above because we want the default
|
|
310
|
+
// browser behavior to open the link when pressing Enter. But we still need to prevent
|
|
311
|
+
// default so that elements above do not also handle it (e.g. table row).
|
|
312
|
+
e.stopPropagation();
|
|
310
313
|
},
|
|
311
314
|
onKeyUp (e) {
|
|
312
|
-
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard');
|
|
315
|
+
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard');
|
|
313
316
|
},
|
|
314
317
|
onClick (e) {
|
|
315
318
|
if (e && !e.currentTarget.contains(e.target)) return;
|
|
@@ -331,7 +334,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
331
334
|
}
|
|
332
335
|
};
|
|
333
336
|
let onKeyUp = (e)=>{
|
|
334
|
-
if (state.isPressed && $0294ea432cd92340$var$isValidKeyboardEvent(e)) {
|
|
337
|
+
if (state.isPressed && $0294ea432cd92340$var$isValidKeyboardEvent(e, state.target)) {
|
|
335
338
|
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
|
|
336
339
|
e.stopPropagation();
|
|
337
340
|
state.isPressed = false;
|
|
@@ -340,7 +343,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
340
343
|
removeAllGlobalListeners();
|
|
341
344
|
// If the target is a link, trigger the click method to open the URL,
|
|
342
345
|
// but defer triggering pressEnd until onClick event handler.
|
|
343
|
-
if (state.target instanceof HTMLElement &&
|
|
346
|
+
if (state.target instanceof HTMLElement && state.target.contains(target) && ($0294ea432cd92340$var$isHTMLAnchorLink(state.target) || state.target.getAttribute('role') === 'link')) state.target.click();
|
|
344
347
|
}
|
|
345
348
|
};
|
|
346
349
|
if (typeof PointerEvent !== 'undefined') {
|
|
@@ -572,9 +575,9 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
572
575
|
function $0294ea432cd92340$var$isHTMLAnchorLink(target) {
|
|
573
576
|
return target.tagName === 'A' && target.hasAttribute('href');
|
|
574
577
|
}
|
|
575
|
-
function $0294ea432cd92340$var$isValidKeyboardEvent(event) {
|
|
576
|
-
const { key: key , code: code
|
|
577
|
-
const element =
|
|
578
|
+
function $0294ea432cd92340$var$isValidKeyboardEvent(event, currentTarget) {
|
|
579
|
+
const { key: key , code: code } = event;
|
|
580
|
+
const element = currentTarget;
|
|
578
581
|
const { tagName: tagName , isContentEditable: isContentEditable } = element;
|
|
579
582
|
const role = element.getAttribute('role');
|
|
580
583
|
// Accessibility for keyboards. Space and Enter only.
|