From 23bba7e760be346a66ed8545cd9257bfd94b2536 Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Tue, 13 Oct 2026 13:36:32 -0400 Subject: [PATCH] Teleport every modal to , fixing an unclickable-behind-page bug Reported from the sidebar's own per-document delete: the confirm modal appeared behind the main content and couldn't be clicked. Root cause: .app-sidebar (position:sticky) and .txn-col (container-type:inline-size, which implies layout containment) each always create their own CSS stacking context, with or without an explicit z-index. ConfirmModal/DocumentOptionsModal/DownloadChoiceModal are rendered as DOM descendants of one or the other depending on which call site opens them, so their own z-index:50 was trapped inside that ancestor's local stacking order - no z-index value could escape it, since z-index only ever competes against siblings within the same stacking context. Fixed with on all three modals - the standard fix for this bug, not a bigger z-index (which cannot escape a trapped stacking context regardless of the number). Each modal now always renders as a direct child of , a sibling of #app rather than a descendant of whichever component opened it, so this can't recur regardless of which future component ends up opening one. Verified: npm run build passes, the bundle references Teleport, the app container rebuilt. measure.py unaffected. Not machine-verified - Claude-in-Chrome did not connect this session. Co-Authored-By: Claude Sonnet 5 --- CLAUDE.md | 26 +++++++ frontend/src/components/ConfirmModal.vue | 56 +++++++++----- .../src/components/DocumentOptionsModal.vue | 74 ++++++++++--------- .../src/components/DownloadChoiceModal.vue | 56 ++++++++------ 4 files changed, 135 insertions(+), 77 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 89c3525..773ccc8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1450,6 +1450,32 @@ separate computed with no dependency on `SourceDocumentPanel`'s state at all. Fi confirmed bug; **did not claim the transactions-table symptom is resolved** - asked the user to retest specifically that, since no code path was found connecting the two. +**All three modal components teleported to ``, fixing a real "modal appears behind +the page, unclickable" bug reported from the sidebar's own per-document delete.** Root +cause: `.app-sidebar` (`position:sticky`) and `.txn-col` (`container-type:inline-size`, +which implies layout containment) each create their own CSS stacking context - ALWAYS, +with or without an explicit z-index. `ConfirmModal`/`DocumentOptionsModal`/ +`DownloadChoiceModal` are all rendered as DOM descendants of one or the other depending +on which call site opened them, so their own `.modal-overlay`'s `z-index:50` was +**trapped inside that ancestor's local stacking order** - no z-index value could have +fixed this, since z-index is only ever compared against siblings within the SAME +stacking context; `.app-sidebar`/`.txn-col` themselves have no elevated z-index of their +own, so their entire subtree (modal included) could be painted under later, unrelated +page content regardless of what number the modal's own z-index carried. + +Fixed with `` wrapping each modal's root element - the standard Vue +fix for this exact class of bug, not a bigger z-index (which cannot escape a stacking- +context trap no matter the value chosen). All three modals now always render as a +direct child of ``, a SIBLING of `#app` rather than a descendant of whichever +component happened to open them, so they're never trapped inside any ancestor's +stacking context again, regardless of which future component ends up opening one. + +Verified: `npm run build` passes; the built bundle confirmed to reference `Teleport`; +the `app` container rebuilt. `measure.py` unaffected (no backend touched). Not +machine-verified: whether the modal now actually appears above everything and is +clickable from every call site (sidebar delete, document delete, move-to-project, +download choice) - Claude-in-Chrome still did not connect this session. + **Governing rule: never silently correct or exclude data.** This shows up in several concrete places, not just as an abstract principle: - A row with an unusual status (e.g. HSBC's "Cancelled" wires) stays in the output and is diff --git a/frontend/src/components/ConfirmModal.vue b/frontend/src/components/ConfirmModal.vue index 9c2d5b9..b7f474e 100644 --- a/frontend/src/components/ConfirmModal.vue +++ b/frontend/src/components/ConfirmModal.vue @@ -5,8 +5,22 @@ * A small, generic confirm/cancel modal - originally built for * TransactionsTable's "Move to project" dropdown, now also reused for * destructive document deletion (see DocumentNavBar.vue's "Delete this - * document" flow) - `danger` swaps the confirm button to the red/danger - * treatment for that case. + * document" flow, and ProjectSidebar.vue's own per-document delete) - + * `danger` swaps the confirm button to the red/danger treatment for + * that case. + * + * Rendered via - several call sites live inside an + * ancestor that creates its own CSS stacking context (.app-sidebar has + * position:sticky; .txn-col has container-type:inline-size, which + * implies layout containment - both always create one, with or without + * an explicit z-index). A modal nested inside either gets its own + * z-index trapped within that ancestor's local stacking order, no + * matter how high the value - it can be painted UNDER later, unrelated + * page content regardless (confirmed for real: the sidebar's own delete + * confirm rendered behind the main content, unclickable). Teleporting + * to renders it outside any ancestor's stacking context entirely, + * the standard fix for this class of bug - not a z-index increase, which + * cannot fix a trapped stacking context no matter the number chosen. */ import { toRef } from 'vue' import { useModalFocus } from '../composables/useModalFocus' @@ -28,24 +42,26 @@ const { overlayRef } = useModalFocus(toRef(props, 'visible')) diff --git a/frontend/src/components/DocumentOptionsModal.vue b/frontend/src/components/DocumentOptionsModal.vue index 39c2053..cb8c2cc 100644 --- a/frontend/src/components/DocumentOptionsModal.vue +++ b/frontend/src/components/DocumentOptionsModal.vue @@ -7,6 +7,12 @@ * ConfirmModal for the actual delete (DocumentNavBar owns that step - * same two-modal "pick an action, then confirm the destructive one" * pattern already established by "Move to project"). + * + * Rendered via - its own call site lives inside + * .txn-col, which creates its own CSS stacking context + * (container-type:inline-size implies layout containment) - see + * ConfirmModal.vue's own comment for the full reasoning and the real + * bug this fixes. */ import { ref, toRef, watch } from 'vue' import { useModalFocus } from '../composables/useModalFocus' @@ -32,41 +38,43 @@ function handleRename() { diff --git a/frontend/src/components/DownloadChoiceModal.vue b/frontend/src/components/DownloadChoiceModal.vue index 0bc0b31..69bbabb 100644 --- a/frontend/src/components/DownloadChoiceModal.vue +++ b/frontend/src/components/DownloadChoiceModal.vue @@ -6,6 +6,12 @@ * more than one document is loaded - replaces the old separate "Download * All" button with one Download button that asks which, rather than * needing a second button in the UI for the "all" case. + * + * Rendered via - its own call site lives inside + * .txn-col, which creates its own CSS stacking context + * (container-type:inline-size implies layout containment) - see + * ConfirmModal.vue's own comment for the full reasoning and the real + * bug this fixes. */ import { toRef } from 'vue' import { useModalFocus } from '../composables/useModalFocus' @@ -20,30 +26,32 @@ const { overlayRef } = useModalFocus(toRef(props, 'visible'))