Skip to content

fix(admin): keep confirm dialog buttons in place while pending - #5258

Open
khoinguyenpham04 wants to merge 4 commits into
noah/layout-shift-content-typesfrom
noah/layout-shift-pending-labels
Open

khoinguyenpham04 wants to merge 4 commits into
noah/layout-shift-content-typesfrom
noah/layout-shift-pending-labels

Conversation

@khoinguyenpham04

@khoinguyenpham04 khoinguyenpham04 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Stops the confirm button in confirmation dialogs from resizing when you confirm. It swapped its label for the pending text, such as "Moving to trash...", so it resized under the pointer: the trash confirmation's button grew 24 px wider.

Both labels now share one grid cell in every ConfirmDialog. The inactive one is invisible and aria-hidden, so the button keeps the width of the longer label and its accessible name stays the visible label. The idle button is now as wide as its longer label. The button can shrink to fit the dialog, and a label too long for it, such as Italian's 40-character pending text for Discarding..., ends in an ellipsis instead of running past the dialog's edge.

ContentEditor.test.tsx now finds the delete confirmation's button by role. Its old locator matched on text content, which now includes the hidden pending label.

Type of change

  • Bug fix
  • Feature (requires an accepted feature plan or RFC)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Your connection to this change

  • I use EmDash and ran into the problem this PR addresses
  • I maintain a tool, dependency, or service that EmDash uses, and this change concerns that integration
  • A Maintainer approved this specific change before I opened the PR

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main. Not applicable: no new strings.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to their merged design PR: https://github.com/emdash-cms/emdash/pull/... Not applicable: bug fix.
  • I have included screenshots below if this PR changes the UI

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: Claude Opus 5.5

Screenshots / test output

Measured on the demos/simple production build, served gzipped, with the cache disabled and Slow 4G throttling, at 390 px with a 4× CPU slowdown and at 1440 px. The Slow 4G recordings attached at the end show the old build on the left and this one on the right.

Move to Trash confirmation on a 390 px phone, before confirming on the left of each image and while the request runs on the right

Before After
Move to Trash dialog before the change. The Move to Trash button grows 24 px to the left when its label changes to Moving to trash Move to Trash dialog after the change. The button is the same width and position before confirming and while it reads Moving to trash

Regression test that fails on main and passes here:

  • ConfirmDialog.test.tsx: "keeps both buttons in place on %s while its request runs", at 390 px and 1280 px.
  • ConfirmDialog.test.tsx: "keeps a long pending label inside a small phone's dialog", at 320 px. It checks that the visible label stays inside the button in both states and that the pending label ends in an ellipsis.

On the top of the stack, pnpm build, pnpm typecheck, pnpm lint:quick (0 diagnostics), pnpm format and the full admin suite (369 files, 5,822 tests) pass.

trash-confirm-phone-slow-4g.mp4

@changeset-bot

changeset-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d5a9ec9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-test Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@5258

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@5258

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@5258

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@5258

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@5258

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@5258

emdash

npm i https://pkg.pr.new/emdash@5258

create-emdash

npm i https://pkg.pr.new/create-emdash@5258

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@5258

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@5258

@emdash-cms/plugin-test

npm i https://pkg.pr.new/@emdash-cms/plugin-test@5258

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@5258

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@5258

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@5258

@emdash-cms/registry-loader

npm i https://pkg.pr.new/@emdash-cms/registry-loader@5258

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@5258

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@5258

upgrade-emdash

npm i https://pkg.pr.new/upgrade-emdash@5258

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@5258

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@5258

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@5258

@emdash-cms/plugin-ai-search

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-search@5258

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@5258

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@5258

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@5258

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@5258

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@5258

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@5258

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@5258

commit: d5a9ec9

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs d5a9ec9 Dec 04 2026, 08:10 PM

@khoinguyenpham04
khoinguyenpham04 marked this pull request as ready for review December 3, 2026 16:58

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach is sound. Stacking both the normal and pending labels in one grid cell reserves space for the wider label, so the shared ConfirmDialog button no longer resizes when it enters the pending state. This needs no hard-coded width. The inactive label is hidden from assistive technology, so the visible label stays the accessible name. The new regression test measures real button positions and widths at phone and desktop viewports, and the updated ContentEditor locator is more robust. Both reviewers approved, and neither ran the tests. One non-blocking suggestion remains: the new test resets the viewport only on its last line, so an earlier failure would leave later tests at the narrow width.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

@emdashbot emdashbot Bot added the review/needs-review No maintainer or bot review yet label Dec 3, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The follow-up is the right change: wrapping the regression test in try/finally restores the viewport even when rendering or an assertion fails, without changing what the test verifies.

The earlier viewport-cleanup suggestion is addressed. I reviewed the follow-up diff and surrounding test code; no new issues remain. Review was static; I did not run tests or other tooling.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

@khoinguyenpham04
khoinguyenpham04 force-pushed the noah/layout-shift-pending-labels branch from 7e83eb1 to 0e3905f Compare December 3, 2026 17:35

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach remains appropriate: reserving space for both confirmation labels prevents pending-state layout shifts, while truncation accommodates narrow dialogs and hidden labels stay out of the accessible name.

I reviewed the follow-up diff and surrounding implementation and tests. The earlier viewport-cleanup suggestion remains addressed with try/finally, including the narrow-dialog regression test. No new issues to fix were found in this PR.

Review was static; I did not run tests, builds, or other checks.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

@khoinguyenpham04
khoinguyenpham04 force-pushed the noah/layout-shift-pending-labels branch from 0e3905f to a0707fe Compare December 3, 2026 18:01

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach remains appropriate: reserving space for both labels prevents pending-state button movement while preserving the visible label as the accessible name.

I reviewed the supplied follow-up diff and relevant surrounding code and tests. The earlier viewport-cleanup suggestion remains addressed with try/finally, including in the narrow-dialog regression test. No new issues to fix were found.

Review was static; I did not run tests, builds, or other checks.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.

Worker Status Deployment Commit
emdash-playground Deployed Preview 1
Preview 2
d5a9ec9

Updated: Dec 4, 2026, 20:11 UTC | Dashboard

@khoinguyenpham04
khoinguyenpham04 force-pushed the noah/layout-shift-pending-labels branch from a0707fe to cdd0327 Compare December 4, 2026 10:55

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach remains appropriate: reserving space for both confirmation labels prevents pending-state button movement while keeping the visible label as the accessible name.

I compared the supplied follow-up with the current PR diff and checked the dialog implementation, layout regression tests, role-based delete-confirmation locator, and changeset. The earlier viewport-cleanup suggestion remains addressed with try/finally in both layout tests. No new issues to fix were found in the PR-specific changes.

Review was static; I did not run tests, builds, or other checks.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

@emdashbot emdashbot Bot added review/needs-review No maintainer or bot review yet and removed review/needs-review No maintainer or bot review yet labels Dec 4, 2026
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Dec 4, 2026
The confirm button swapped its label for the pending text, so it
resized under the pointer. Both labels now share one grid cell, the
inactive one hidden and aria-hidden, so the button keeps the wider
label's width and its name stays the visible label. The editor's delete
test now finds the confirm button by role rather than by its text
content, which includes the hidden label.
The pending-width test resized the viewport and only restored it on its
last line, so a failed assertion left later tests in the file at the
phone width.
The confirm button reserved the width of its longer label but kept the
button's own w-max shrink-0, so a long translated pending label, such as
Italian's for Discarding..., pushed it past a phone dialog's edge even
before confirming. The button can now shrink to the footer, and its
labels end in an ellipsis when they don't fit.
The label grid's track now has a zero minimum, so the button's min-content
width doesn't depend on how an engine sizes a truncated grid item. The
test now checks that the visible label sits inside the button and that a
long pending label ends in an ellipsis.
@github-actions github-actions Bot added the size/M label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants