Experimental Image Cropper: Tweak the keyboard interactions with drag handles and canvas#77639
Conversation
…les, canvas, and shift behaviour
|
Size Change: +452 B (+0.01%) Total Size: 7.76 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 5fe6fe4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24873143541
|
ramonjd
left a comment
There was a problem hiding this comment.
This is a nice upgrade to the interaction. I like that the handles are selected and are usable by keyboard straight away. In my testing they're selected and deselected when I expect, and the clockwise order is 👍🏻
2026-04-24.14.28.31.mp4
Just had a question about whether the CSS should be opinionated and how much?
But really, it's not a blocker. What you have LGTM.
🚢
| transition: background-color 0.15s ease, box-shadow 0.15s ease; | ||
|
|
||
| &:focus { | ||
| outline: none; | ||
| } | ||
|
|
||
| // Double ring (white inner + theme-color outer) for legibility | ||
| // over the dark dimming overlay. | ||
| &:focus-visible { | ||
| background: var(--wp-admin-theme-color, #007cba); | ||
| border-color: transparent; | ||
| box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-admin-theme-color, #007cba); | ||
| } |
There was a problem hiding this comment.
Do you think this should be default, or overridden by the consumer?
My thinking was we'd have all interactive elements as vanilla as they can be so different use cases (e.g., mobile might want different handles) can overwrite the CSS with minimal changes.
No blockers here.
There was a problem hiding this comment.
Oh, good point! Yes I was a bit focused on hacking it in there I completely forgot about our layers of abstraction here and that image-editor might one day be an independent package. I'll have a play around, but yes, I reckon we want a default styling for the component itself, and the WP implementation can override with the wp-admin color 👍
There was a problem hiding this comment.
I went a little back-and-forth playing around with this one and settled on using a CSS variable named --wp-image-editor-focus-color and falling back to --wp-admin-theme-color if available (pushed in 5fe6fe4). I'm possibly overthinking it, but here's what was on my mind:
- If/when we move
image-editorto be used as a package, it could be that plugins might make use of the image editor, and it'd be good for it to "just work" with a WordPress context without any extra configuration - But we also want the image editor to be easily configurable outside of WordPress and to not depend on WP existing
So that's where I landed. I imagine we'll be tweaking the API of this a lot in coming PRs but it seemed an okay balance to me for now.
I'll aim to merge this once tests pass, but let me know if you feel otherwise!
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
… handles and canvas (#77639) * Experimental Image Cropper: Tweak keyboard interactions for drag handles, canvas, and shift behaviour * Don't rotate if a modifier key is held when r is pressed * Add a CSS variable so that consumers can override the focus color Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: simison <87168+simison@users.noreply.github.com>

What?
Follows / part of:
Tweak the keyboard interactions for the experimental image cropper in the media editor:
These are admittedly opinionated changes, but they're weakly held ideas! Based on some chatter with @ramonjd from #77591, and I'm happy to scale this back / split things out if anything feels off.
Why?
Oftentimes folks might switch between keyboard and mouse while interacting with cropping tools and the overall idea here is to try to make that handoff feel as smooth as possible, while also feeling consistent with some other apps that do cropping.
How?
onEscapecallback to the stencil so that we can move focus back to the canvasTesting Instructions
Screenshots or screencast
cropping-keyboard.mp4
Use of AI Tools
Mostly Claude Code with Sonnet 4.6, with a little tweaking by hand.