Skip to content

Fix: Dimensions tool: Aspect ratio icons look blurry next to the Original icon - #86344

Merged
hbhalodia merged 7 commits into
WordPress:trunkfrom
hbhalodia:fix/issue-86297
Nov 5, 2026
Merged

hbhalodia merged 7 commits into
WordPress:trunkfrom
hbhalodia:fix/issue-86297

Conversation

@hbhalodia

Copy link
Copy Markdown
Contributor

What?

Closes #86297

The ratio icons in the Aspect ratio dropdown now have sharp outlines, like the Original icon next to them. This follows up on #85812, as suggested in this review comment.

Why?

Each icon's edges are worked out from its ratio, and they often land on whole numbers, halves or thirds. The 1.5px line centred on those edges then covers only part of a pixel on each side, so the browser blurs it. The generic aspect ratio icon puts its edges at .25 and .75, so its line covers whole pixels on a 2x display.

How?

  • Adds a snapToPixels() helper that moves an edge to the nearest .25 or .75.
  • Snaps the left and top edges, and mirrors them for the right and bottom edges, so the shape stays centred.
  • Snapping moves each edge by at most a quarter of a pixel. For example, 16:9 draws at 1.82 instead of 1.78. Standard 4:3 now uses exactly the generic icon's frame.
  • The result matches the "After" screenshot in the review comment.

shape-rendering="crispEdges" would also remove the blur, but it makes the rounded corners jagged, so it's not being used.

Testing Instructions

  1. On a 2x (Retina) display, insert an Image block, add an image, and keep the block selected.
  2. In the block settings sidebar, open the Aspect ratio dropdown.
  3. Zoom into a screenshot of the list. Each ratio icon is as sharp as Original, and Standard - 4:3 has the same frame as Original.
  4. Choose Wide - 16:9. The icon in the closed dropdown is sharp too.
  5. In Storybook, check the AspectRatioTool stories WithOptions and CustomRatio.

Screenshots or screencast

Before After
Image Screenshot 2026-11-04 at 5 53 14 PM

Use of AI Tools

I used Claude Code (Claude Opus 5.5) to trace the cause and draft the fix and this description. I reviewed and tested the changes myself.

@hbhalodia
hbhalodia requested a balanced review from Copilot November 5, 2026 05:03
@hbhalodia hbhalodia self-assigned this Nov 5, 2026
@hbhalodia
hbhalodia requested a review from ellatrix as a code owner November 5, 2026 05:03
@hbhalodia hbhalodia added [Type] Enhancement A suggestion for improvement. [Package] Editor /packages/editor [Feature] Layout Layout block support, its UI controls, and style output. labels Nov 5, 2026
@github-actions github-actions Bot added [Package] Block editor /packages/block-editor and removed [Package] Editor /packages/editor labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the aspect-ratio icon update.

No open issues 🎉

What changed in this PR

Addresses #86297 by sharpening the aspect ratio icons in Gutenberg’s Dimensions tool on 2× displays.

Changes:

  • Snaps rectangle edges to quarter-pixel positions and mirrors opposite edges to keep icons centered.
  • Adds a block-editor changelog entry for the visual fix.
File Description
packages/​block-editor/​src/​components/​dimensions-tool/​aspect-ratio-icon.tsx Adds pixel snapping for sharper, centered icon outlines.
packages/​block-editor/​CHANGELOG.md Documents the aspect ratio icon fix.

Review effort: Balanced

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just some small ideas for simplification.

Comment thread .dev-ready Resolved
@hbhalodia

Copy link
Copy Markdown
Contributor Author

Thanks @mirka, I have updated the PR with changes. Here is before and after images after feedbacks,

Before After
Screenshot 2026-11-05 at 5 31 13 PM Screenshot 2026-11-05 at 5 28 12 PM

Have resolved the conversations, as they are applied here in commit 8622f56 and d6e71cb

@hbhalodia
hbhalodia requested review from mirka and a balanced review from Copilot November 5, 2026 12:07

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the aspect ratio icon sharpness update.

No open issues 🎉

Review effort: Balanced

@hbhalodia
hbhalodia merged commit 96b16af into WordPress:trunk Nov 5, 2026
90 checks passed
@hbhalodia
hbhalodia deleted the fix/issue-86297 branch November 5, 2026 13:10
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Layout Layout block support, its UI controls, and style output. [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dimensions tool: Aspect ratio icons look blurry next to the Original icon

3 participants