Skip to content

fix(admin): make image actions reliably selectable - #2490

Open
khoinguyenpham04 wants to merge 2 commits into
mainfrom
fix/image-actions-2478
Open

fix(admin): make image actions reliably selectable#2490
khoinguyenpham04 wants to merge 2 commits into
mainfrom
fix/image-actions-2478

Conversation

@khoinguyenpham04

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes image action controls intermittently failing to appear in the Portable Text editor. Images now become selected on the primary pointer-down event, so slight pointer movement before release does not lose the selection, and the actions remain visible while the image is selected.

Closes #2478

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

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.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: N/A — this is a bug fix.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: GPT-5 Codex

Screenshots / test output

  • Added a Chromium regression test that reproduces the failure with six pixels of pointer drift.
  • packages/admin: 120 test files and 1,423 tests passed.
  • Full workspace typecheck, type-aware lint, and formatting checks passed.
  • Manually verified imprecise mouse selection, touch selection, keyboard focus, image settings, quick alt editing, and Arabic RTL positioning.

@changeset-bot

changeset-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2557aad

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

This PR includes changesets to release 17 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash 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

@cloudflare-workers-and-pages

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 skipped
View logs
emdash-demo-do 2557aad Aug 16 2026, 01:45 PM

@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet area/admin size/M labels Aug 16, 2026
@cloudflare-workers-and-pages

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
emdash-demo-cache 2557aad Aug 16 2026, 01:48 PM

@cloudflare-workers-and-pages

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
emdash-playground 2557aad Aug 16 2026, 01:49 PM

@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.

This PR targets the right problem with a focused, idiomatic fix. Moving image selection from the unreliable click event to pointerdown means small pointer drift no longer prevents the image from being selected, and removing the hover-only opacity keeps the actions visible while the image is selected. The approach fits EmDash's TipTap/React node view architecture and is consistent with how the editor handles block selection.

What I checked:

  • Read the diff and the full ImageNode.tsx, plus the new regression test.
  • Compared with sibling node views (GalleryNode, HtmlBlockNode, PluginBlockNode, CodeBlockNode) to confirm this is an image-specific fix rather than a systemic pattern change.
  • Verified the changeset follows the release-note style and that all UI strings remain Lingui-wrapped and Tailwind logical-class usage is RTL-safe.
  • Confirmed the admin package runs browser tests via vitest-browser-react + Playwright, so the getComputedStyle assertion in the regression test runs against a real Chromium DOM.

The guard in handlePointerDown (editor.isEditable, event.isPrimary, event.button !== 0, typeof getPos() === "number") is correct, and setNodeSelection(getPos()) is the right ProseMirror API for selecting a block node. The test reproduces the exact failure mode (six pixels of pointer drift) and asserts the observable outcome (settings button becomes visible). No AGENTS.md convention violations. LGTM.

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

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

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/registry-verification

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

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 2557aad

@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 Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/admin review/approved Approved; no new commits since size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image Settings options intermittently unavailable

1 participant