Skip to content

[6.x] Keep the asset picker on one row in narrow fields - #16175

Merged
jaygeorge merged 6 commits into
6.xfrom
16175-narrow-asset-picker-copy
Dec 4, 2026
Merged

jaygeorge merged 6 commits into
6.xfrom
16175-narrow-asset-picker-copy

Conversation

@jaygeorge

@jaygeorge jaygeorge commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description of the Problem

In a narrow Assets field (a single-file field on a phone, or in a half-width column), the picker squeezes "or choose a file" into a sliver beside the Browse button, so it breaks across three lines. The link is a button, so its text is centred too, which makes it look scattered. When the field has a dynamic folder, the "…" menu sits in the same row and makes it tighter still.

A bit wider, the full stop after "choose a file" could also wrap onto a line of its own.

image

What this PR Does

  • Below 31rem the picker uses its short layout, "Browse · or upload", kept on one line
  • Above that it's the full layout as before, with the text wrapping beside Browse Assets
  • The full stop stays with the link, so it can't wrap on its own
  • The 0/1 badge stays tucked in the top corner (from [6.x] Align the maximum items badge to the top #15299), but centres when the "…" menu is next to it, since everything else in that row is centred
  • Adds the short "upload" string to each language file, using the existing "Upload" translation

Why 31rem rather than 24rem

The switch used to be at 24rem, but the full layout still wrapped above that once the badge and the "…" were both there. I checked the language files and French has the longest "Browse Assets" ("Parcourir les ressources"). With the badge and "…" showing, the French row needs just over 30rem, so 31rem keeps it on one row in every language.

I did try measuring the row with a ResizeObserver and switching only when it actually wraps. It worked, but it was a lot more code for a few pixels of difference, so a fixed container query felt like the better trade.

Before / After

image

How to Reproduce

  1. Add an Assets field in list mode with max_files: 1 and a dynamic folder (e.g. dynamic: slug), so the badge and the "…" menu both show
  2. Open an entry and make the window narrow enough that the field is under 24rem
  3. On 6.x "or choose a file" wraps across three lines; on this branch it reads "or upload" on one row

- Narrow fields say "or upload" next to Browse, without wrapping
- Centre the file count badge on the row
- Below 30rem the short layout stays on one line; above it the text wraps beside Browse Assets as before
- 30rem fits the longest translation (French) without the row wrapping
- Keep the full stop with the upload link
- Centre the file count badge only when the rename folder menu is there
@jaygeorge
jaygeorge merged commit 315e451 into 6.x Dec 4, 2026
66 checks passed
@jaygeorge
jaygeorge deleted the 16175-narrow-asset-picker-copy branch December 4, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant