mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-20 17:13:49 +00:00
fix(editors): focus the dialog without selecting its name field
Cancel the non-bubbling FocusScope mount event in the capture phase and focus the dialog itself. Keep keyboard navigation working without highlighting the name or opening the touch keyboard automatically.
This commit is contained in:
1 parent
2035f9f476
commit
462f1db833
5 files changed
+35
-2
No files matched your search
@@ -18,7 +18,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord
|
||||
- Per-group webhook ingress: optional `POST /webhook/{groupId}` with a per-group secret in KV (`tenant:{groupId}`) — Gitea/classic-GitHub/custom webhooks are verified against the group's secret instead of the operator's global ones; only that group's routes fire. The legacy `POST /webhook` (global secrets, all routes) stays untouched
|
||||
- GitHub App tenant isolation: `Group.installationId` binds a group to one GitHub App installation; events whose `payload.installation.id` differs are rejected at dispatch (hard isolation on top of the optional `owners` list). The App's Setup URL points at `GET /auth/github/install`, which renders a choice page (create `inst-{installationId}` or bind to a group the signed-in user owns, verified by role); `POST /auth/github/install/bind` performs the provisioning. `installation.created` webhook events auto-provision as a fallback (create `inst-{installationId}` or bind existing groups whose `owners` match the installing account)
|
||||
- GitHub OAuth: octokit (token is stored hashed for reverse lookup)
|
||||
- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/groups/{groupId}` a group's routes, members and webhook · `/admin/logs` · `/admin/audit` · `/admin/metrics`, parsed by `app/utils/admin-path.ts`; the admin page's `validate` 404s any other path); every page is a history entry, so the browser's back button returns from a group to the list (no in-page back button) and leaving with an open editor or an unsaved route order asks first; sign-out asks for confirmation (sidebar, or a top-right button on narrow screens); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies
|
||||
- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/groups/{groupId}` a group's routes, members and webhook · `/admin/logs` · `/admin/audit` · `/admin/metrics`, parsed by `app/utils/admin-path.ts`; the admin page's `validate` 404s any other path); every page is a history entry, so the browser's back button returns from a group to the list (no in-page back button) and leaving with an open editor or an unsaved route order asks first; sign-out asks for confirmation (sidebar, or a top-right button on narrow screens); editor dialogs open without focusing a field (`useDialogFocus`); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies
|
||||
- Access control: every group has role-based members (`owner` / `admin` / `viewer`); super admins bypass; legacy `adminIds` are read as owners (backward compatible); owners manage members + invites; `owners` field stays super-only
|
||||
- Invites: single-use 7-day links (`invite:{token}`) for joining a group as admin/viewer; `ALLOW_SELF_SIGNUP=1` gives access-less users a personal group on first login (self-service SaaS entry)
|
||||
- Audit log: every admin operation (logins, group/route/member/invite changes) recorded in D1 `audit_logs`; pruned by the scheduled trigger after `AUDIT_RETENTION_DAYS` (default 90)
|
||||
@@ -42,7 +42,7 @@ app/ # Vue 3 UI (Nuxt app dir)
|
||||
│ # ConfirmDialog (app-wide destructive-action confirm), SendLogs, AuditLog, MetricsPanel,
|
||||
│ # AppToasts, LegalLayout
|
||||
├── composables/ # useI18n, useToasts, useConfirm (promise-based confirm), useBackdropGuard (editor dialogs ignore
|
||||
│ # backdrop clicks), useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs,
|
||||
│ # backdrop clicks), useDialogFocus (editor dialogs open without focusing a field), 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, admin-path.ts (console URL parsing),
|
||||
|
||||
@@ -553,6 +553,11 @@
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
/* The dialog itself takes focus on open (useDialogFocus); its fields show the ring. */
|
||||
.editor-dialog:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.editor-dialog > div:first-child {
|
||||
margin-bottom: 0 !important;
|
||||
flex-shrink: 0 !important;
|
||||
|
||||
@@ -345,6 +345,7 @@ function close(): void {
|
||||
|
||||
// A click on the backdrop must not discard what has been typed so far.
|
||||
const { isBackdropClose } = useBackdropGuard(() => props.open, ".editor-dialog");
|
||||
useDialogFocus(() => props.open, ".editor-dialog");
|
||||
|
||||
function onOpenChange(open: boolean): void {
|
||||
if (!open && !isBackdropClose()) close();
|
||||
|
||||
@@ -260,6 +260,7 @@ function close(): void {
|
||||
|
||||
// A click on the backdrop must not discard what has been typed so far.
|
||||
const { isBackdropClose } = useBackdropGuard(() => props.open, ".editor-dialog");
|
||||
useDialogFocus(() => props.open, ".editor-dialog");
|
||||
|
||||
function onOpenChange(open: boolean): void {
|
||||
if (!open && !isBackdropClose()) close();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Opens an editor dialog without jumping into its first field. reka-ui's
|
||||
* FocusScope focuses and *selects* the first input on open, which highlights
|
||||
* the name as if about to overwrite it and pops up the keyboard on touch
|
||||
* screens. Its mount auto-focus is announced with a non-bubbling, cancelable
|
||||
* event — RcDialog exposes no `openAutoFocus` hook — so it is caught here in
|
||||
* the capture phase and focus goes to the dialog itself instead: Escape and
|
||||
* Tab keep working, the fields stay untouched until the user picks one.
|
||||
*/
|
||||
export function useDialogFocus(isOpen: () => boolean, dialogSelector: string) {
|
||||
function onMountAutoFocus(event: Event): void {
|
||||
const dialog = event.target;
|
||||
if (!(dialog instanceof HTMLElement) || !dialog.matches(dialogSelector)) return;
|
||||
event.preventDefault();
|
||||
dialog.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
function listen(on: boolean): void {
|
||||
if (typeof document === "undefined") return;
|
||||
if (on) document.addEventListener("focusScope.autoFocusOnMount", onMountAutoFocus, true);
|
||||
else document.removeEventListener("focusScope.autoFocusOnMount", onMountAutoFocus, true);
|
||||
}
|
||||
|
||||
watch(isOpen, listen, { immediate: true });
|
||||
onBeforeUnmount(() => listen(false));
|
||||
}
|
||||
Reference in new issue
Block a user