[PR #7334] [MERGED] fix(client): keep avatar crop handles whole on square images #7685

Closed
opened 2026-10-24 04:06:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7334
Author: @SpicyMarinara
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/7323-crop-handles-square


📝 Commits (7)

  • bf70f35 fix(client): keep avatar crop handles whole on square images
  • 529f9ac test(e2e): type the crop handle corner points
  • 745f598 Merge origin/staging into fix/7323-crop-handles-square
  • 473f6ba fix(client): stop crop handle touch targets scrolling the editor on phones
  • c9cc92e Merge origin/staging into fix/7323-crop-handles-square
  • 800b580 Merge origin/staging into fix/7323-crop-handles-square
  • 4e90c78 Move the CHANGELOG entry away from other open PRs

📊 Changes

3 files changed (+181 additions, -70 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 e2e/avatar-preview.e2e.ts (+83 -0)
📝 packages/client/src/components/ui/AvatarCropWidget.tsx (+97 -70)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7323

Why this change

  • A square avatar (512x512, 1024x1024, ...) opens Avatar Crop with the crop covering the whole picture, so the crop sits on every image edge. The crop frame and its corner handles were drawn inside the image's clipped, rounded box, so each handle was cut down to a tiny sliver in the picture's corner. The reporter used the editor for about a month before noticing the handles existed, and the grab area left over was only a few pixels.
  • Root cause: packages/client/src/components/ui/AvatarCropWidget.tsx put the crop overlay (frame outline, 44px touch targets and drawn handles) inside the relative overflow-hidden rounded-lg canvas. Handles are centered on the crop corners, so whenever a corner touched the image edge, three quarters of the handle, most of its touch target and the frame outline were clipped, and the rounded corner clipped the rest. Wide and tall pictures had the same problem on their long edges.

What changed

  • The crop canvas is now a stage with a 12px gutter around the image. Only the image and the dimming outside the crop stay clipped; the frame and corner handles are drawn in the unclipped stage, so they stay whole and keep their full 44px touch targets at the image edge.
  • The image gives up the gutter (fits in 336px instead of 360px), so the widget keeps the same footprint on desktop and mobile.
  • On phones the stage nearly fills the editor's width, so the touch targets' sideways reach is trimmed at the 12px gutter there (max-md:overflow-x-clip). Without that, the targets reached 24px past the stage and made the character and persona editors scroll sideways (scrollWidth 399 > 390 at 390px, 401 > 393 on iPhone 15 Pro). The drawn handles stay whole, the vertical reach is unchanged, and the desktop/tablet row layout keeps the full 44px reach.
  • The drawn handle grows from 14px to 16px. The default crop (centered max square), the saved crop format and the crop math are unchanged.
  • The crop frame and handles get data-avatar-crop-frame / data-avatar-crop-handle hooks for the new browser test.
  • e2e/avatar-preview.e2e.ts: a new test opens a character with a 1024x1024 avatar, checks that all four handles are at least 16px and whole and on top at each corner, checks that no ancestor of the crop frame scrolls sideways, then drags the outer edge of the bottom-right handle (the part that used to be clipped) to shrink the crop.
  • CHANGELOG entry under [Unreleased].

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify in a desktop browser that a character with a square avatar shows four whole white corner handles in Avatar Crop, and that dragging each one resizes the crop.
  • Manually verify the same for a persona with a square avatar (Persona editor).
  • Manually verify a wide and a tall avatar: handles on the long edges are whole, panning still works, and Reset still returns to the centered max square.
  • Manually verify on a phone-width viewport that the crop stage still fits as before and the handles can be dragged by touch.
  • Manually verify the crop still saves and the circle preview matches the square.

Agent-run checks: pnpm check passed (localization, format, lint, e2e types, build). node ./scripts/run-regressions.mjs --filter scripts/regressions/avatar-crop-contract.regression.ts passed. playwright test e2e/avatar-preview.e2e.ts passed on desktop-chromium, mobile-chromium and mobile-webkit (6/6). The new crop-handle test was also run against the old layout (staging widget plus only the test hooks and a 16px handle): it failed with three of the four corners of the top-left handle clipped, so it pins this bug. Local CodeRabbit (coderabbit review --agent --committed) completed with 0 findings. The PR's browser e2e jobs are skipped on pull requests, so the browser test above only ran locally.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Before (from the report): the handles are clipped to slivers in the image corners. After: the new browser test saves square-crop-handles.png in its test output.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7334 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7323-crop-handles-square` --- ### 📝 Commits (7) - [`bf70f35`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bf70f3557aa929b7489fe0d2fb86462d3c8d2b88) fix(client): keep avatar crop handles whole on square images - [`529f9ac`](https://github.com/Pasta-Devs/Marinara-Engine/commit/529f9ac259e784f31ea5b34dadb22bf706cec41b) test(e2e): type the crop handle corner points - [`745f598`](https://github.com/Pasta-Devs/Marinara-Engine/commit/745f598803e9fb81383aa4ff2ca7e15e6eb8b522) Merge origin/staging into fix/7323-crop-handles-square - [`473f6ba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/473f6babda7c15bfa6cf983eb4090364a0e4f394) fix(client): stop crop handle touch targets scrolling the editor on phones - [`c9cc92e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c9cc92e0752c9925c643b79c1b3088a923a4707c) Merge origin/staging into fix/7323-crop-handles-square - [`800b580`](https://github.com/Pasta-Devs/Marinara-Engine/commit/800b580cea7108266045533da79541cd038a7aca) Merge origin/staging into fix/7323-crop-handles-square - [`4e90c78`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4e90c784e392fac946d001296904c7b0742abc8d) Move the CHANGELOG entry away from other open PRs ### 📊 Changes **3 files changed** (+181 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `e2e/avatar-preview.e2e.ts` (+83 -0) 📝 `packages/client/src/components/ui/AvatarCropWidget.tsx` (+97 -70) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7323 ## Why this change - A square avatar (512x512, 1024x1024, ...) opens **Avatar Crop** with the crop covering the whole picture, so the crop sits on every image edge. The crop frame and its corner handles were drawn inside the image's clipped, rounded box, so each handle was cut down to a tiny sliver in the picture's corner. The reporter used the editor for about a month before noticing the handles existed, and the grab area left over was only a few pixels. - Root cause: `packages/client/src/components/ui/AvatarCropWidget.tsx` put the crop overlay (frame outline, 44px touch targets and drawn handles) inside the `relative overflow-hidden rounded-lg` canvas. Handles are centered on the crop corners, so whenever a corner touched the image edge, three quarters of the handle, most of its touch target and the frame outline were clipped, and the rounded corner clipped the rest. Wide and tall pictures had the same problem on their long edges. ## What changed - The crop canvas is now a stage with a 12px gutter around the image. Only the image and the dimming outside the crop stay clipped; the frame and corner handles are drawn in the unclipped stage, so they stay whole and keep their full 44px touch targets at the image edge. - The image gives up the gutter (fits in 336px instead of 360px), so the widget keeps the same footprint on desktop and mobile. - On phones the stage nearly fills the editor's width, so the touch targets' sideways reach is trimmed at the 12px gutter there (`max-md:overflow-x-clip`). Without that, the targets reached 24px past the stage and made the character and persona editors scroll sideways (scrollWidth 399 > 390 at 390px, 401 > 393 on iPhone 15 Pro). The drawn handles stay whole, the vertical reach is unchanged, and the desktop/tablet row layout keeps the full 44px reach. - The drawn handle grows from 14px to 16px. The default crop (centered max square), the saved crop format and the crop math are unchanged. - The crop frame and handles get `data-avatar-crop-frame` / `data-avatar-crop-handle` hooks for the new browser test. - `e2e/avatar-preview.e2e.ts`: a new test opens a character with a 1024x1024 avatar, checks that all four handles are at least 16px and whole and on top at each corner, checks that no ancestor of the crop frame scrolls sideways, then drags the outer edge of the bottom-right handle (the part that used to be clipped) to shrink the crop. - CHANGELOG entry under [Unreleased]. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify in a desktop browser that a character with a square avatar shows four whole white corner handles in **Avatar Crop**, and that dragging each one resizes the crop. - Manually verify the same for a persona with a square avatar (Persona editor). - Manually verify a wide and a tall avatar: handles on the long edges are whole, panning still works, and **Reset** still returns to the centered max square. - Manually verify on a phone-width viewport that the crop stage still fits as before and the handles can be dragged by touch. - Manually verify the crop still saves and the circle preview matches the square. Agent-run checks: `pnpm check` passed (localization, format, lint, e2e types, build). `node ./scripts/run-regressions.mjs --filter scripts/regressions/avatar-crop-contract.regression.ts` passed. `playwright test e2e/avatar-preview.e2e.ts` passed on desktop-chromium, mobile-chromium and mobile-webkit (6/6). The new crop-handle test was also run against the old layout (staging widget plus only the test hooks and a 16px handle): it failed with three of the four corners of the top-left handle clipped, so it pins this bug. Local CodeRabbit (`coderabbit review --agent --committed`) completed with 0 findings. The PR's browser e2e jobs are skipped on pull requests, so the browser test above only ran locally. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Before (from the report): the handles are clipped to slivers in the image corners. After: the new browser test saves `square-crop-handles.png` in its test output. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:31 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7685
No description provided.