mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-20 17:13:49 +00:00
fix(editors): ignore accidental backdrop dismissal
Do not discard unsaved route or group edits when the user clicks outside the dialog. Preserve Escape, Cancel and explicit close, including popovers and confirmation dialogs stacked above the editor.
This commit is contained in:
1 parent
628d5af5f3
commit
a8418c06d9
6 files changed
+58
-5
No files matched your search
@@ -41,7 +41,8 @@ app/ # Vue 3 UI (Nuxt app dir)
|
||||
│ # AST builder + FilterCombobox searchable inputs), GroupEditor, MembersPanel, WebhookPanel,
|
||||
│ # ConfirmDialog (app-wide destructive-action confirm), SendLogs, AuditLog, MetricsPanel,
|
||||
│ # AppToasts, LegalLayout
|
||||
├── composables/ # useI18n, useToasts, useConfirm (promise-based confirm), useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs,
|
||||
├── composables/ # useI18n, useToasts, useConfirm (promise-based confirm), useBackdropGuard (editor dialogs ignore
|
||||
│ # backdrop clicks), useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs,
|
||||
│ # useAudit, useInvites, useWebhook
|
||||
├── types.ts # shared client types (Route, Group, Filter, ...)
|
||||
└── utils/ # legal.ts (terms/privacy HTML bodies, zh/en), format.ts,
|
||||
|
||||
@@ -343,8 +343,11 @@ function close(): void {
|
||||
emit("close");
|
||||
}
|
||||
|
||||
// A click on the backdrop must not discard what has been typed so far.
|
||||
const { isBackdropClose } = useBackdropGuard(() => props.open, ".editor-dialog");
|
||||
|
||||
function onOpenChange(open: boolean): void {
|
||||
if (!open) close();
|
||||
if (!open && !isBackdropClose()) close();
|
||||
}
|
||||
|
||||
function save(): void {
|
||||
|
||||
@@ -258,8 +258,11 @@ function close(): void {
|
||||
emit("close");
|
||||
}
|
||||
|
||||
// A click on the backdrop must not discard what has been typed so far.
|
||||
const { isBackdropClose } = useBackdropGuard(() => props.open, ".editor-dialog");
|
||||
|
||||
function onOpenChange(open: boolean): void {
|
||||
if (!open) close();
|
||||
if (!open && !isBackdropClose()) close();
|
||||
}
|
||||
|
||||
async function runTest(): Promise<void> {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Keeps an editor dialog open when the user clicks outside it, so a stray click
|
||||
* on the backdrop never throws away unsaved input. RcDialog exposes no hook for
|
||||
* reka's `interactOutside`, so this watches pointer-downs while the dialog is
|
||||
* open: a press outside the dialog (and outside any popover or dialog stacked
|
||||
* above it) marks the close request it triggers as one to ignore. Escape, the
|
||||
* close button and Cancel keep closing the dialog.
|
||||
*/
|
||||
export function useBackdropGuard(isOpen: () => boolean, dialogSelector: string) {
|
||||
let pressedOutside = false;
|
||||
|
||||
function onPointerDown(event: PointerEvent): void {
|
||||
const target = event.target as Element | null;
|
||||
pressedOutside = !target?.closest?.(
|
||||
`${dialogSelector}, [data-dismissable-layer], [data-reka-popper-content-wrapper]`,
|
||||
);
|
||||
}
|
||||
|
||||
function onKeyDown(): void {
|
||||
pressedOutside = false;
|
||||
}
|
||||
|
||||
function listen(on: boolean): void {
|
||||
if (typeof document === "undefined") return;
|
||||
if (on) {
|
||||
document.addEventListener("pointerdown", onPointerDown, true);
|
||||
document.addEventListener("keydown", onKeyDown, true);
|
||||
return;
|
||||
}
|
||||
document.removeEventListener("pointerdown", onPointerDown, true);
|
||||
document.removeEventListener("keydown", onKeyDown, true);
|
||||
pressedOutside = false;
|
||||
}
|
||||
|
||||
watch(isOpen, listen, { immediate: true });
|
||||
onBeforeUnmount(() => listen(false));
|
||||
|
||||
/** Whether the pending close request came from a press outside the dialog. */
|
||||
function isBackdropClose(): boolean {
|
||||
const outside = pressedOutside;
|
||||
pressedOutside = false;
|
||||
return outside;
|
||||
}
|
||||
|
||||
return { isBackdropClose };
|
||||
}
|
||||
@@ -65,7 +65,7 @@ For local debugging only, set `DEBUG_MODE=true` to bypass GitHub OAuth and grant
|
||||
|
||||
The console is served as an SPA at `/admin`; its tabs are deep-linkable via the URL path (`/admin/groups`, `/admin/logs`, `/admin/audit`). URLs outside `/admin` that do not match an endpoint return a plain `404` instead of the console.
|
||||
|
||||
Destructive actions — deleting routes, groups, filter conditions, fragments, targets or forge hosts, removing members, revoking invites, disabling a group's webhook — ask for confirmation in an in-app dialog (empty, never-filled rows are removed directly).
|
||||
Destructive actions — deleting routes, groups, filter conditions, fragments, targets or forge hosts, removing members, revoking invites, disabling a group's webhook — ask for confirmation in an in-app dialog (empty, never-filled rows are removed directly). The route and group editors ignore clicks on the backdrop so unsaved input is never lost; close them with Cancel, ✕ or <kbd>Esc</kbd>.
|
||||
|
||||
All management endpoints (`/admin/api/*`) are documented in the [Admin API](../api/admin). Saved routes and groups are persisted to D1 (`d1_routes` / `d1_groups`) immediately, the KV cache is invalidated and the config cache is refreshed so the webhook pipeline picks them up on the next run.
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ WebHooker 在 `/admin` 提供内置配置控制台,可在浏览器中管理路
|
||||
|
||||
控制台以 SPA 形式在 `/admin` 提供;其标签页可通过 URL 路径直达(`/admin/groups`、`/admin/logs`、`/admin/audit`)。`/admin` 之外未匹配到端点的 URL 直接返回 `404`,而不会展示控制台。
|
||||
|
||||
删除类操作——删除路由、分组、过滤条件、片段、目标或来源主机,移除成员,撤销邀请,停用分组 webhook——都会先弹出应用内确认框(从未填写过的空行直接删除)。
|
||||
删除类操作——删除路由、分组、过滤条件、片段、目标或来源主机,移除成员,撤销邀请,停用分组 webhook——都会先弹出应用内确认框(从未填写过的空行直接删除)。路由与分组编辑弹窗点击遮罩不会关闭,避免丢失未保存的内容;请用「取消」、✕ 或 <kbd>Esc</kbd> 关闭。
|
||||
|
||||
所有管理端点(`/admin/api/*`)见 [Admin API](../api/admin)。保存的路由和分组会立即持久化到 D1(`d1_routes` / `d1_groups`),并使 KV 缓存失效、刷新配置缓存,下一次 webhook 处理即会生效。
|
||||
|
||||
|
||||
Reference in new issue
Block a user