Repository navigation
fix: make draw-credit ? shortcut cooperative so only one overlay opens (#1173) - #1329
Merged
greatest0fallt1me merged 2 commits intoOct 24, 2026
Merged
greatest0fallt1me merged 2 commits into
greatest0fallt1me merged 2 commits into
Conversation
Creditra#1173) Move the draw wizard's keyboard handler to a capture-phase document listener that always consumes ? (preventDefault + stopPropagation), so App's bubble-phase handler skips it and the global ShortcutHelpOverlay can no longer stack with the wizard's InlineHelpOverlay. Wizard shortcuts stay inert while any aria-modal dialog is open, and ? in a focused input is left alone. Also: restore the learn-mode branch so acknowledging ?learn=1 no longer writes the ack key (regressed in e3cb4ee), fix the stale risk-gate and Start-over test expectations, upgrade the test router stub with route matching + window.location support, mock useWalletIdentityKey for the confirm step, and add the App-level integration suite.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # package-lock.json # package.json # src/components/TransactionStatus.tsx # src/pages/DrawCreditPage.test.tsx # src/test/__mocks__/react-router-dom.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1173
Problem
Pressing
?on/draw-creditopened two overlays: App's document-level bubble listener (App.tsx) openedShortcutHelpOverlay, then the draw wizard's window-level listener (DrawCreditPage.tsx) opened its ownInlineHelpOverlay— two stacked modals, double-inerted backdrop, broken focus management.Fix
src/pages/DrawCreditPage.tsx— the wizard's shortcut handler now binds in the capture phase ondocumentand always consumes?(preventDefault()+stopPropagation()), so App's handler — which bails onevent.defaultPrevented— never runs on this route. The wizard opens its contextual help only when no other modal is open; while an input is focused the key is ignored entirely (character insertion wins). Escape/arrows are gated behind any open[role="dialog"][aria-modal="true"](scoped so the always-mounted, closed notification-center panel doesn't block shortcuts).docs/ACCESSIBILITY.md— new "Shortcut precedence" section documenting the page-level?vs global?contract.Also included (needed for green acceptance + CI)
e3cb4eedropped the?learn=1branch fromhandleRiskModalAcknowledge, so acknowledging in learn mode started writing the ack key; restored (verified against original21ebc97implementation). Same commit also introduced a TDZ error (handleRiskModalAcknowledgeAndFocusdeps referencing aconstdeclared below it) — fixed by reordering the callbacks (pre-existing in the worktree, load-bearing for any render of the page).e3cb4ee), and a failed draw's reset CTA is "Start over" (per#1179/a250566).src/test/__mocks__/react-router-dom.tsx): realRoutes/Routematching,BrowserRouterreadswindow.location,syncHistory()keeps jsdom's URL in sync — required for App-level routing tests. (Overlaps with the stub upgrade in fix: revalidate restored repay drafts and scope them to the wallet (#1188) #1323 — whichever merges second rebases.)useWalletIdentityKeymock inDrawCreditPage.test.tsx: 10 confirm-step tests were failing on main with "useWallet must be used within WalletProvider" (masked by a collection error until the@stellar/stellar-sdkdep below was added).@stellar/stellar-sdkdependency: without it no test file collects —npm run build/CI on main was red. Added to fix that pre-existing breakage.src/App.test.tsx:/helpis a code-split route, so the input-focus test now awaitsfindByPlaceholderTextinstead ofgetBy…synchronously.Test plan
New
src/App.shortcuts.test.tsx(6 rows):/draw-credit+?→ exactly one dialog, and it is the wizard's Help Center (not "Move around faster")?pressed again with help open → still exactly one dialog/+?→ global ShortcutHelpOverlay still opens (no behavior loss)?→ no second dialog stacked (WhyApr has no UI trigger in the current build, so the reachableDefaultRiskModalstands in for the "dialog already open" case)?typed into the amount input → no overlay, still on the amount step, focus retainedEscapecloses the wizard help → focus returns to the "Contact support" triggerVerification
npx vitest run src/pages/DrawCreditPage.test.tsx src/components/ShortcutHelpOverlay.test.tsx src/App.test.tsx src/App.shortcuts.test.tsx→ 70 passed, 0 failed (5 pre-existing skips).aria-hiddenon the entire tree).mainbaseline (both runs with the stellar-sdk dep): 374 → 317 failures, 0 new failures (58 fixed by this PR; the single diff —ConfirmDialogfocus trap — passes in isolation 2×, a full-suite timing flake).npm run build→ succeeds (CI's only job);tsc --noEmit→ 334 errors, unchanged from baseline (repo-wide pre-existing debt; lint has no eslint config on main, pre-existing).