fix(admin): scope body colors and mobile dialog sizing to admin pages - #3867
masonjames wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: e1b762a The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
The approach is sound: scoping the two unlayered admin rules to body:has(> #admin-root) lets the existing admin shell marker decide when the styles apply, so leaking the admin stylesheet onto a public page no longer clobbers public body colors or mobile dialogs. The selector matches the actual admin.astro markup (#admin-root is a direct child of <body>), and portaled dialogs still sit inside that <body> so the mobile width cap still works for admin. The changeset is clear and present-tense.
I checked the markup in packages/core/src/astro/routes/admin.astro, the existing :has() usage elsewhere in styles.css, the Vitest browser config, the AGENTS.md workflow guidance, and the changeset README. The CSS changes themselves look correct. The only concern is the new style regression test importing the built dist/styles.css artifact, which is gitignored and not present on a fresh checkout; without a build first, the test can fail or (worse) pass against stale compiled CSS.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
The approach is sound and the prior concern is resolved in spirit: scoping the two unlayered admin rules to body:has(> #admin-root) matches the admin shell markup in packages/core/src/astro/routes/admin.astro, so leaking the admin stylesheet onto a public page no longer clobbers public body colors or mobile dialogs, while portaled admin dialogs still inherit the width cap. The previous review's worry about importing a gitignored, potentially stale dist/styles.css is now addressed with a pre-test build step.
I checked the scoped selectors against the admin Astro markup, the three new browser tests, the Vitest browser config, the Tailwind CLI usage, and the changeset. The only remaining issue is the command used in the new pre-test build step: it invokes pnpm exec tailwindcss, while the package's own build script uses npx @tailwindcss/cli. In Tailwind v4 the CLI is @tailwindcss/cli, and the lockfile only marks that package as hasBin: true; the tailwindcss package itself does not advertise a bin. Matching the existing build command makes the pre-test step reliable on a fresh checkout and in CI.
What does this PR do?
When the admin stylesheet reaches a public page, its unlayered body colors override layered theme styles, and its mobile dialog rule narrows full-screen navigation overlays by 32px.
Scope these two rules to
body:has(> #admin-root). Dialogs remain descendants of the admin body, so the mobile width limit still applies when they portal outside#admin-root. No new page marker or runtime changes are needed.The dev-only stylesheet traces are outside this patch, as allowed in the maintainer approval.
Addresses #1811 (body and dialog scoping).
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
pnpm format, rootpnpm build,pnpm typecheck,pnpm lint:quick, and type-awarepnpm --silent lint:jsonpass (zero diagnostics).pnpm --filter @emdash-cms/admin test run tests/styles.test.tspasses (3 tests).Verified in a disposable local copy of masonjames.com at revision
52f683c(EmDash 1.1.0 / Astro 7.3.5), with a seeded local database and local storage. To exercise the leakage scenario, the compiled admin CSS was explicitly loaded on public pages and the site's existing body/menu workarounds were removed only in that disposable copy. The served fixed CSS matches the built artifact byte-for-byte.At a 390 × 844 viewport:
oklch(0.98 0 0)oklch(0.972 0.018 92)oklch(0.12 0 0)oklch(0.205 0.032 172)#admin-root, light and darkBefore/after public-menu screenshots and the Arabic admin dialog screenshot are attached below.