Skip to content

fix(audit-sprint-6b): z-index scale broader adoption + --z-toast token - #172

Closed
ejay-dev wants to merge 1 commit into
fix/audit-sprint-4c-modal-primitivesfrom
fix/audit-sprint-6b-z-index-scale
Closed

fix(audit-sprint-6b): z-index scale broader adoption + --z-toast token#172
ejay-dev wants to merge 1 commit into
fix/audit-sprint-4c-modal-primitivesfrom
fix/audit-sprint-6b-z-index-scale

Conversation

@ejay-dev

Copy link
Copy Markdown
Owner

Summary

The 280-z-index survey from the audit deep-dive: peaks at z-[10000], scattered values z-[49], z-[60], z-[70], z-[80]. Turns out globals.css:32-41 already had a 10-value scale — it was just barely adopted. This PR broadens adoption to the primitives + ad-hoc surfaces that survive Phase 2/3, plus adds the missing --z-toast token.

Base branch: fix/audit-sprint-4c-modal-primitives (PR #167).

Scope decision

The user asked for "full migration: all 30 ad-hoc modals". On inspection, most of those 30 are slated for replacement by the new Dialog/AlertDialog/Sheet primitives in Modal Phase 2/3. Fixing their z-index now would be reverted by the migration. So this PR establishes:

  1. The primitives on the token scale (Dialog, AlertDialog, Sheet, Toaster)
  2. The surfaces that will remain (CookieConsent, CommandPalette)

Once Phase 2/3 migrations land, every dialog automatically inherits the right layer from the primitive. Net win.

Changes

File Before After
app/globals.css 10-value scale, no toast band +--z-toast: 110 (above tour). Comment expanded with rationale per band
components/ui/dialog.tsx overlay+content both z-50 (broken — content relied on DOM order) overlay → var(--z-modal-backdrop), content → var(--z-modal)
components/ui/alert-dialog.tsx same broken z-50 pair token-scaled
components/ui/sheet.tsx same token-scaled
components/ui/toaster.tsx no z-index var(--z-toast) — sits above tour
components/CookieConsent.tsx z-[60] hardcoded var(--z-overlay)
components/command-palette/CommandPalette.tsx both z-50 var(--z-modal-backdrop) + var(--z-modal)

What this PR does NOT touch

  • The 23 remaining ad-hoc modal surfaces — they're getting replaced by Phase 2/3 migrations anyway
  • 183 z-10 / 38 z-50 page-decoration uses (sticky headers etc) — not modal-scoped
  • tailwind.config.ts extend.zIndex with utility classes — inline style is cleaner here

Validation

  • npm run type-check clean
  • npm run lint 0 errors, 18 warnings (baseline)
  • npx jest 5319/5334 pass (no test changes)

Test plan

  • Open a Dialog while a product tour is running → tour above dialog backdrop, below an active toast
  • toast.error() while a Sheet is open → toast visible at bottom-right above sheet
  • Open command palette while CookieConsent showing → command palette covers banner correctly

🤖 Generated with Claude Code

Background: app/globals.css already had a 10-value z-index scale, but
adoption was sparse — only the product-tour overlays used the CSS vars,
while modal/overlay/command-palette surfaces all hardcoded `z-50`,
`z-[60]`, etc. Result was the chaotic survey: 280 z-index uses, peaks
at z-[10000] for panic-level layers.

This PR doesn't migrate all 30 ad-hoc modal surfaces (most are slated
for replacement by the Sprint 4c primitives — fixing their z-index now
is wasted work). It establishes the *primitives* and the *surfaces
that will remain* on the token scale, so once Phase 2/3 modal
migrations land, every dialog automatically sits in the right layer.

Changes
  - app/globals.css: new `--z-toast: 110` token between `--z-tour` (100)
    and `--z-debug` (120). Toasts must sit above tour overlays so a
    critical toast firing during a product tour stays visible. Scale
    comment expanded with the why for each band.
  - components/ui/dialog.tsx, alert-dialog.tsx: overlay →
    var(--z-modal-backdrop), content → var(--z-modal). Was z-50 for
    both (broken — content would never render above its own backdrop
    on equal z; relied on DOM order).
  - components/ui/sheet.tsx: same treatment.
  - components/ui/toaster.tsx: sonner root → var(--z-toast).
  - components/CookieConsent.tsx: was z-[60] hardcoded →
    var(--z-overlay). Banner now sits above page chrome, below modals
    + tour + toast — correct precedence.
  - components/command-palette/CommandPalette.tsx: was z-50 for both
    backdrop and content → token-scaled. Cmd-K now plays nicely with
    a tour overlay calling it out.

What this PR does NOT touch
  - The 23 remaining ad-hoc modal surfaces (per the modal-audit agent's
    inventory). Each is slated for replacement by Dialog/AlertDialog/
    Sheet in Phase 2/3 — fixing their z-index now would be reverted
    when the migration happens. The new primitives already use the
    token scale, so the migration is a net win on z-index too.
  - The 183 z-10 / 38 z-50 page-decoration uses. Most are sticky
    headers and visual layering, not modal-scoped, no conflict to fix.
  - tailwind.config.ts: not extended with z- utility classes. Inline
    style stays cleaner here because CSS variables in Tailwind's
    `extend.zIndex` require either arbitrary-value syntax or a
    rebuild step; inline style sidesteps both.

Built on top of fix/audit-sprint-4c-modal-primitives (PR #167)
because the Dialog/AlertDialog/Toaster primitives live there.

Validation
  - tsc -p tsconfig.typecheck.json: clean
  - eslint: 0 errors, 18 warnings (baseline)
  - jest: 5319/5334 pass (no test changes)

Test plan
  - Open a Dialog while a product tour is running — tour overlay
    should be above the dialog backdrop but below an active toast.
  - Trigger toast.error() while a Sheet is open — toast visible at
    bottom-right above the sheet.
  - Open command palette while CookieConsent is showing — command
    palette eats the banner correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented May 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
forma-os Ready Ready Preview, Comment May 23, 2026 3:49pm

Request Review

Copilot AI review requested due to automatic review settings May 23, 2026 15:45
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c941eb85-b696-4445-a66f-e7fda21c8741

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-sprint-6b-z-index-scale

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR broadens adoption of the existing CSS z-index token scale to key modal/toast primitives and a couple of long-lived overlay surfaces, and adds a missing --z-toast token to ensure toasts reliably layer above product tours.

Changes:

  • Adds --z-toast to app/globals.css and documents the intended z-index band ordering.
  • Updates Dialog / AlertDialog / Sheet primitives (and CommandPalette) to use token-based z-index for backdrops and content.
  • Ensures Sonner toasts and CookieConsent use tokenized z-index values rather than hardcoded utility classes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/globals.css Adds --z-toast and expands documentation for the z-index token bands.
components/ui/dialog.tsx Moves dialog overlay/content off z-50 utility and onto tokenized z-index via inline style.
components/ui/alert-dialog.tsx Same token-based z-index migration for alert dialog overlay/content.
components/ui/sheet.tsx Same token-based z-index migration for sheet overlay/content.
components/ui/toaster.tsx Applies zIndex: var(--z-toast) to Sonner Toaster to sit above tours.
components/CookieConsent.tsx Replaces hardcoded z-[60] with --z-overlay.
components/command-palette/CommandPalette.tsx Replaces z-50 on backdrop/container with modal token z-indexes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/ui/dialog.tsx
Comment on lines +50 to 54
style={{ zIndex: 'var(--z-modal-backdrop)' }}
className={cn(
"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
"fixed inset-0 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
)}
Comment on lines +42 to 46
// Audit Sprint 6b: token-scaled (see app/globals.css).
style={{ zIndex: 'var(--z-modal-backdrop)' }}
className={cn(
"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
"fixed inset-0 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
Comment thread components/ui/sheet.tsx
Comment on lines +31 to 35
// Audit Sprint 6b: token-scaled to match dialog/alert-dialog.
style={{ zIndex: 'var(--z-modal-backdrop)' }}
className={cn(
"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",
"fixed inset-0 bg-black/60 backdrop-blur-sm",
className
@ejay-dev
ejay-dev deleted the branch fix/audit-sprint-4c-modal-primitives May 23, 2026 16:55
@ejay-dev ejay-dev closed this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants