Repository navigation
Experimental Image Cropper: Ensure focus is on canvas when dragging #77591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrewserong
merged 2 commits into
trunk
from
update/image-cropper-ensure-focus-on-canvas-after-drag
Apr 24, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good call. This works well. I'm also thinking that when the keyboard is panning the dim layer could also lighten like it does when mouse dragging.
2026-04-23.19.41.10.mp4
Here's how I tested:
diff
On a side note, I activated
showGridlocally. Do you think we should show the grid by default?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, this is just an interesting nice to have. I think the keyboard functionality we have here is way more valuable than screen bling. I'm just wondering if it's worth thinking about how to indicate visually when the image is focussed and therefore pannable. Or if it's worth it at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think it's valuable to think about for sure! My main goal at the moment was to try to look at it in little pieces. I'm not too sure about the focused state of the canvas itself, but when it comes to the drag handles, I could see having a focus style on them when dragging with the mouse, so it's clear what's focused, and we could do a similar thing of allowing keyboard controls at that stage, too.
My preference would be to not show the grid as it interferes with looking at the image itself. Something for us to play with could be either a) for the grid to show only while dragging, rotating, moving the crop etc, and then have it fade out, or b) have a toggle in the sidebar to control display. But I reckon let's look at the grid separately (good thinking, though!)
For now, I'll fix up the tests in this PR and see how we go. Then in a follow-up, I'd like to look at focusing the drag handles, and play around with visually indicating what's focused. What do you reckon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a follow-up, just jotting down what Google Photos does for the drag handles. If you tab to them it's got a nice big focus styles to make it clear what you've got selected:
(It also uses circles instead of squares, not sure if we have a preference there)
In any case, happy to play around with it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. All these ideas are good. We can test them out later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the browser takes care of it by default: