@jsenv/navi 0.26.33 → 0.26.35
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/jsenv_navi.js +32 -54
- package/dist/jsenv_navi.js.map +4 -5
- package/package.json +2 -2
package/dist/jsenv_navi.js
CHANGED
|
@@ -20282,10 +20282,15 @@ const useExecuteAction = (
|
|
|
20282
20282
|
removeErrorMessage();
|
|
20283
20283
|
setError(null);
|
|
20284
20284
|
|
|
20285
|
-
const
|
|
20285
|
+
const element = elementRef.current;
|
|
20286
|
+
const validationMessageTarget = requester || element;
|
|
20286
20287
|
validationMessageTargetRef.current = validationMessageTarget;
|
|
20287
20288
|
|
|
20288
|
-
dispatchPublicCustomEvent(
|
|
20289
|
+
dispatchPublicCustomEvent(
|
|
20290
|
+
element,
|
|
20291
|
+
"navi_action_start",
|
|
20292
|
+
sharedActionEventDetail,
|
|
20293
|
+
);
|
|
20289
20294
|
|
|
20290
20295
|
return action[method]({
|
|
20291
20296
|
reason: `"${event.type}" event on ${(() => {
|
|
@@ -20304,26 +20309,28 @@ const useExecuteAction = (
|
|
|
20304
20309
|
return `<${tagName}>`;
|
|
20305
20310
|
})()}`,
|
|
20306
20311
|
onAbort: (reason) => {
|
|
20312
|
+
const element = elementRef.current;
|
|
20307
20313
|
if (
|
|
20308
20314
|
// at this stage the action side effect might have removed the <element> from the DOM
|
|
20309
20315
|
// (in theory no because action side effect are batched to happen after)
|
|
20310
20316
|
// but other side effects might do this
|
|
20311
|
-
|
|
20317
|
+
element
|
|
20312
20318
|
) {
|
|
20313
|
-
dispatchPublicCustomEvent("navi_action_abort", {
|
|
20319
|
+
dispatchPublicCustomEvent(element, "navi_action_abort", {
|
|
20314
20320
|
...sharedActionEventDetail,
|
|
20315
20321
|
reason,
|
|
20316
20322
|
});
|
|
20317
20323
|
}
|
|
20318
20324
|
},
|
|
20319
20325
|
onError: (error) => {
|
|
20326
|
+
const element = elementRef.current;
|
|
20320
20327
|
if (
|
|
20321
20328
|
// at this stage the action side effect might have removed the <element> from the DOM
|
|
20322
20329
|
// (in theory no because action side effect are batched to happen after)
|
|
20323
20330
|
// but other side effects might do this
|
|
20324
|
-
|
|
20331
|
+
element
|
|
20325
20332
|
) {
|
|
20326
|
-
dispatchPublicCustomEvent("navi_action_error", {
|
|
20333
|
+
dispatchPublicCustomEvent(element, "navi_action_error", {
|
|
20327
20334
|
...sharedActionEventDetail,
|
|
20328
20335
|
error,
|
|
20329
20336
|
});
|
|
@@ -20335,13 +20342,14 @@ const useExecuteAction = (
|
|
|
20335
20342
|
}
|
|
20336
20343
|
},
|
|
20337
20344
|
onComplete: (data) => {
|
|
20345
|
+
const element = elementRef.current;
|
|
20338
20346
|
if (
|
|
20339
20347
|
// at this stage the action side effect might have removed the <element> from the DOM
|
|
20340
20348
|
// (in theory no because action side effect are batched to happen after)
|
|
20341
20349
|
// but other side effects might do this
|
|
20342
|
-
|
|
20350
|
+
element
|
|
20343
20351
|
) {
|
|
20344
|
-
dispatchPublicCustomEvent("navi_action_end", {
|
|
20352
|
+
dispatchPublicCustomEvent(element, "navi_action_end", {
|
|
20345
20353
|
...sharedActionEventDetail,
|
|
20346
20354
|
data,
|
|
20347
20355
|
});
|
|
@@ -31545,11 +31553,11 @@ const SelectWithPopover = props => {
|
|
|
31545
31553
|
anchor: ref.current
|
|
31546
31554
|
});
|
|
31547
31555
|
};
|
|
31548
|
-
const
|
|
31556
|
+
const disableClickFor = useIgnoreClickForMousedown();
|
|
31549
31557
|
const requestClose = (e = new CustomEvent("programmatic")) => {
|
|
31550
31558
|
if (e.type === "mousedown") {
|
|
31551
31559
|
debugPopup(formatEventSideEffect(e, `disable click`));
|
|
31552
|
-
disableClickFor(
|
|
31560
|
+
disableClickFor();
|
|
31553
31561
|
}
|
|
31554
31562
|
return requestPopoverClose(popoverRef.current, {
|
|
31555
31563
|
event: e
|
|
@@ -31593,10 +31601,6 @@ const SelectWithPopover = props => {
|
|
|
31593
31601
|
// click triggered by enter won't open the popover
|
|
31594
31602
|
return;
|
|
31595
31603
|
}
|
|
31596
|
-
if (shouldIgnoreThatClick) {
|
|
31597
|
-
debugPopup(formatEventSideEffect(e, `ignore click`));
|
|
31598
|
-
return;
|
|
31599
|
-
}
|
|
31600
31604
|
// When a label is clicked it transfers focus to the select
|
|
31601
31605
|
// in that case we want to open it (otherwise we have already opened on mousedown interaction)
|
|
31602
31606
|
requestOpen(e);
|
|
@@ -31731,11 +31735,11 @@ const SelectWithDialog = props => {
|
|
|
31731
31735
|
event: e
|
|
31732
31736
|
});
|
|
31733
31737
|
};
|
|
31734
|
-
const
|
|
31738
|
+
const disableClickFor = useIgnoreClickForMousedown();
|
|
31735
31739
|
const requestClose = (e = new CustomEvent("programmatic")) => {
|
|
31736
31740
|
if (e.type === "mousedown") {
|
|
31737
31741
|
debugPopup(formatEventSideEffect(e, `disable click`));
|
|
31738
|
-
disableClickFor(
|
|
31742
|
+
disableClickFor();
|
|
31739
31743
|
}
|
|
31740
31744
|
return requestDialogClose(dialogRef.current, {
|
|
31741
31745
|
event: e
|
|
@@ -31778,12 +31782,6 @@ const SelectWithDialog = props => {
|
|
|
31778
31782
|
// click triggered by enter won't open the dialog
|
|
31779
31783
|
return;
|
|
31780
31784
|
}
|
|
31781
|
-
if (shouldIgnore) {
|
|
31782
|
-
debugPopup(formatEventSideEffect(e, `ignore click`));
|
|
31783
|
-
// mousedown on the select already handled open/close; ignore this click
|
|
31784
|
-
// to avoid toggling the dialog again on mouseup
|
|
31785
|
-
return;
|
|
31786
|
-
}
|
|
31787
31785
|
// When a label is clicked it transfers focus to the select, in that case we want to open it
|
|
31788
31786
|
requestOpen(e);
|
|
31789
31787
|
},
|
|
@@ -31855,8 +31853,8 @@ const useSelectRequestClose = () => {
|
|
|
31855
31853
|
};
|
|
31856
31854
|
|
|
31857
31855
|
/**
|
|
31858
|
-
*
|
|
31859
|
-
* handled an open/close action.
|
|
31856
|
+
* Returns a `disableClickFor` function that suppresses the `click` event that
|
|
31857
|
+
* the browser fires after a `mousedown` which already handled an open/close action.
|
|
31860
31858
|
*
|
|
31861
31859
|
* Problem: when the user clicks a dialog's backdrop to close it, the browser
|
|
31862
31860
|
* fires `mousedown` on the backdrop (which closes the dialog), then fires
|
|
@@ -31864,47 +31862,27 @@ const useSelectRequestClose = () => {
|
|
|
31864
31862
|
* element is the trigger button that originally opened the dialog, the `click`
|
|
31865
31863
|
* would immediately re-open it.
|
|
31866
31864
|
*
|
|
31867
|
-
* This problem only occurs when the dialog is closed on `mousedown`. If the
|
|
31868
|
-
* dialog were closed on `click` instead, the dialog would still be open when
|
|
31869
|
-
* the `click` fires on the backdrop, so the trigger button underneath would
|
|
31870
|
-
* never receive that `click`.
|
|
31871
|
-
*
|
|
31872
31865
|
* Calling `stopPropagation()` or `preventDefault()` on the backdrop `mousedown`
|
|
31873
31866
|
* does not help: the browser dispatches the subsequent `click` regardless,
|
|
31874
31867
|
* targeting whichever element ends up under the pointer after the dialog closes.
|
|
31875
31868
|
*
|
|
31876
|
-
*
|
|
31877
|
-
*
|
|
31878
|
-
* // In onMouseDown (e.g. on the dialog backdrop): disableClickFor(e)
|
|
31879
|
-
* // In onClick (on the trigger): if (shouldIgnoreThatClick) return;
|
|
31880
|
-
*
|
|
31881
|
-
* `disableClickFor` arms the guard until the next `mouseup` on the document
|
|
31882
|
-
* (with a 1 s safety-net fallback), using `requestAnimationFrame` so the
|
|
31883
|
-
* `click` event — which fires synchronously after `mouseup` — is still blocked.
|
|
31869
|
+
* Solution: register a self-removing capture-phase `click` listener on `document`
|
|
31870
|
+
* so the click is intercepted before it reaches any element handler.
|
|
31884
31871
|
*/
|
|
31885
31872
|
const useIgnoreClickForMousedown = () => {
|
|
31886
|
-
const pendingMousedownRef = useRef(false);
|
|
31887
|
-
const shouldIgnore = pendingMousedownRef.current;
|
|
31888
31873
|
const disableClickFor = () => {
|
|
31889
|
-
|
|
31890
|
-
|
|
31891
|
-
|
|
31892
|
-
|
|
31893
|
-
|
|
31894
|
-
const safetyTimeout = setTimeout(() => {
|
|
31895
|
-
pendingMousedownRef.current = false;
|
|
31896
|
-
restoreClick();
|
|
31897
|
-
}, 1000);
|
|
31898
|
-
document.addEventListener("mouseup", () => {
|
|
31899
|
-
requestAnimationFrame(() => {
|
|
31900
|
-
restoreClick();
|
|
31874
|
+
const suppressClick = clickEvent => {
|
|
31875
|
+
clickEvent.stopPropagation();
|
|
31876
|
+
clickEvent.preventDefault();
|
|
31877
|
+
document.removeEventListener("click", suppressClick, {
|
|
31878
|
+
capture: true
|
|
31901
31879
|
});
|
|
31902
|
-
}
|
|
31903
|
-
|
|
31880
|
+
};
|
|
31881
|
+
document.addEventListener("click", suppressClick, {
|
|
31904
31882
|
capture: true
|
|
31905
31883
|
});
|
|
31906
31884
|
};
|
|
31907
|
-
return
|
|
31885
|
+
return disableClickFor;
|
|
31908
31886
|
};
|
|
31909
31887
|
|
|
31910
31888
|
/**
|