Skip to content

UI Fieldset: Let long text wrap in narrow containers - #87300

Merged
ciampo merged 3 commits into
trunkfrom
ui/fieldset-shrink-to-container
Nov 25, 2026
Merged

ciampo merged 3 commits into
trunkfrom
ui/fieldset-shrink-to-container

Conversation

@ciampo

@ciampo ciampo commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What?

Found while working on #86732. Fieldset.Root now fits its container, so a child that allows wrapping can show a long filename in full.

Why?

Browsers give <fieldset> a default min-inline-size: min-content. A long filename can make the fieldset wider than its container even when the child sets overflow-wrap: break-word.

How?

Set min-inline-size: 0 alongside the fieldset's existing border, margin, and padding resets in @wordpress/ui. The child still controls how its text wraps.

Testing Instructions

  1. Open the Fieldset → Default story on trunk and on this branch. Use the Storybook toolbar to open the canvas in its own tab.

  2. In the browser console, give the fieldset a 240px container and add the filename.

    const fieldset = document.querySelector( 'fieldset' );
    const container = document.createElement( 'div' );
    container.style.cssText = 'width: 240px; outline: 1px dashed #8c8f94';
    fieldset.before( container );
    container.append( fieldset );
    
    const filename = document.createElement( 'span' );
    filename.textContent = 'QuarterlyFinancialStatementsNovember2026.pdf';
    filename.style.cssText = 'display: block; overflow-wrap: break-word';
    fieldset.append( filename );
  3. On trunk, the filename extends past the dashed outline. On this branch, the entire filename wraps inside it.

Testing Instructions for Keyboard

This changes layout only. Keyboard behavior doesn't change.

Screenshots

The dashed outline marks the same 240px container in both screenshots.

Before (356px fieldset) After (240px fieldset)
The filename extends past the right edge of the container on one line. The full filename wraps onto two lines inside the container.

Use of AI Tools

Claude Code found the cause while building the #86732 examples, wrote the fix, and reproduced the overflow before and after it in Storybook. Codex reviewed the change, corrected the changelog and CSS comment, and captured the screenshots.

🤖 Generated with Claude Code

@ciampo
ciampo requested a review from a team as a code owner November 23, 2026 20:07
@ciampo
ciampo marked this pull request as draft November 23, 2026 20:07
@github-actions

github-actions Bot commented Nov 23, 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: ciampo <mciampini@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.

📦 Bundle size

Size Change: +30 B (0%)

Total Size: 8.71 MB

📦 View Changed
Filename Size Change
build/modules/core-fields/post_type_supports.min.js 82 kB +14 B (+0.02%)
build/scripts/block-editor/index.min.js 561 kB +16 B (0%)

b3249b4 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 7be7a7f trunk % Change
timeToFirstByte 56.85 ms +2.73% -4.57% 55.25 ms +9.59% -2.35% 2.9%
largestContentfulPaint 88 ms +9.09% -4.55% 88 ms +13.64% -6.82% 0%
lcpMinusTtfb 30.4 ms +24.67% -5.26% 29.5 ms +30% -4.92% 3.05%
wpBeforeTemplate 29.13 ms +3.57% -2.78% 28.77 ms +7.82% -1.84% 1.25%
wpTemplate 23.06 ms +2.82% -5.81% 22.47 ms +3.47% -3.56% 2.63%
wpTotal 52.57 ms +3.88% -3.65% 51.64 ms +7.59% -2.89% 1.8%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 7be7a7f trunk % Change
timeToFirstByte 46.5 ms +7.31% -1.29% 46.8 ms +5.13% -1.5% -0.64%
largestContentfulPaint 82 ms +7.32% -2.44% 80 ms +5% -0% 2.5%
lcpMinusTtfb 35.6 ms +10.53% -4.21% 34.15 ms +5.86% -1.61% 4.25%
wpBeforeTemplate 26.76 ms +1.12% -2.09% 26.79 ms +1.68% -1.94% -0.11%
wpTemplate 16.63 ms +5.17% -3.43% 17.12 ms +2.63% -6.02% -2.86%
wpTotal 43.22 ms +6.02% -1.27% 43.7 ms +5.17% -1.83% -1.1%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 7be7a7f trunk % Change
mediaProcessingJpeg 405.1 ms +0.54% -0.49% 402.22 ms +0.41% -0.82% 0.72%
mediaProcessingAvif 6164.05 ms +0.54% -0.08% 6173.41 ms +0.27% -0.48% -0.15%
mediaProcessingJpegToAvif 4258.23 ms +0.06% -0.32% 4248.92 ms +0.16% -0.41% 0.22%

media-upload

Metric 7be7a7f trunk % Change
jpegUploadProcessing 2002.93 ms +1.49% -1.9% 1766.62 ms +12.35% -13.36% 13.38%
pngUploadProcessing 277.8 ms +4.34% -3.34% 284.51 ms +3.22% -2.4% -2.36%
largeJpegUploadProcessing 1990.62 ms +0.46% -0.76% 1952.08 ms +0.58% -21.38% 1.97%
multipleImageUploadProcessing 2109.19 ms +0.07% -2.81% 2080.45 ms +2.88% -0.46% 1.38%

post-editor

Metric 7be7a7f trunk % Change
serverResponse 454.56 ms +9.91% -3.32% 485.86 ms +3.2% -6.72% -6.44%
firstPaint 454.02 ms +3.32% -10.93% 437.69 ms +5.64% -4.42% 3.73%
domContentLoaded 829.34 ms +4.2% -1.21% 834.75 ms +2.57% -0.95% -0.65%
loaded 830.46 ms +4.18% -1.22% 835.92 ms +2.53% -0.94% -0.65%
firstContentfulPaint 470.65 ms +7.71% -2.39% 468.66 ms +4.26% -1.73% 0.42%
firstBlock 2276.39 ms +5.66% -3.12% 2296.38 ms +0.87% -0.88% -0.87%
type 18.94 ms +4.86% -6.76% 18.12 ms +16.17% -5.85% 4.53%
typeWithoutInspector 18.9 ms +3.92% -4.39% 19.25 ms +3.9% -6.03% -1.82%
typeWithTopToolbar 24.98 ms +12.73% -2.52% 22.97 ms +8.32% -3.57% 8.75%
typeContainer 8.68 ms +15.44% -12.79% 9.15 ms +1.97% -11.48% -5.14%
focus 122.75 ms +1.98% -6.88% 113.52 ms +5.41% -4.33% 8.13%
firstFocus 319.58 ms +0% -0% 271.9 ms +0% -0% 17.54%
selectAll 422.35 ms +5.91% -0.55% 396.35 ms +3.92% -4.24% 6.56%
undo 31.93 ms +7.74% -6.95% 30.84 ms +2.82% -10.21% 3.53%
listViewOpen 43.03 ms +2.51% -5.69% 39.68 ms +20.21% -3.28% 8.44%
inserterOpen 50.88 ms +12.4% -13.23% 41.17 ms +6.97% -9.98% 23.59%
inserterHover 12.54 ms +5.26% -8.45% 11.46 ms +12.74% -5.24% 9.42%
inserterSearch 9.08 ms +12.33% -7.93% 8.3 ms +14.22% -4.46% 9.4%
loadPatterns 672.96 ms +5.7% -2.41% 660.84 ms +6.93% -3.24% 1.83%
wpTotal 444.7 ms +10.1% -3.32% 476.06 ms +3.28% -6.88% -6.59%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 7be7a7f trunk % Change
serverResponse 315.82 ms +1.78% -6.78% 313.33 ms +1.81% -7.86% 0.79%
firstPaint 335.55 ms +20.51% -5.29% 366.24 ms +2.94% -13.58% -8.38%
domContentLoaded 669.16 ms +4.8% -1.17% 654.27 ms +2.48% -0.78% 2.28%
loaded 669.88 ms +4.81% -1.16% 655 ms +2.51% -0.77% 2.27%
firstContentfulPaint 384.12 ms +5.27% -3.62% 370.32 ms +2.38% -3.32% 3.73%
firstBlock 2052.85 ms +3.46% -1.6% 2023.17 ms +1.55% -1.24% 1.47%
type 13.98 ms +5.15% -7.37% 15.36 ms +7.49% -5.6% -8.98%
navigate 88.31 ms +11.05% -2.54% 94.35 ms +12.97% -3.23% -6.4%
loadPatterns 1100.63 ms +7.42% -4.7% 1095.23 ms +5% -6.27% 0.49%
loadPages 990.65 ms +3.39% -3.91% 916.9 ms +7.12% -1.18% 8.04%
wpTotal 307.5 ms +1.51% -6.99% 304.96 ms +1.84% -8.08% 0.83%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

b3249b4 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Navigates the list via UP/DOWN arrow keys from action buttons in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-186-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:243:5
should restore an older revision in /test/e2e/specs/editor/various/revisions.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
      "attributes": Object {
-       "content": "Original content - Updated content - Autosaved",
+       "content": "Original content",
      },
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/revisions.spec.js:146:5

b3249b4 Run

@github-actions github-actions Bot added the [Package] UI /packages/ui label Nov 23, 2026
ciampo added a commit that referenced this pull request Nov 23, 2026
The Fieldset fix from #87300 now lets the examples truncate long
filenames, so they no longer need their own min-inline-size reset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ciampo ciampo added the [Type] Bug An existing feature does not function as intended label Nov 23, 2026
@ciampo ciampo self-assigned this Nov 23, 2026
@ciampo
ciampo marked this pull request as ready for review November 23, 2026 21:46
@github-actions
github-actions Bot requested a review from aduth November 23, 2026 21:46
@ciampo ciampo changed the title UI Fieldset: Let content wrap or truncate in a narrow container UI Fieldset: Let long text wrap in narrow containers Nov 23, 2026
ciampo added a commit that referenced this pull request Nov 23, 2026
…ples

Keep "Choose files…" in the panel's header, so it keeps focus when the
first font arrives or the last one is removed. Move focus to the row's
remove button after "Retry", and combine upload results that finish
together into one announcement. Check the file type in the upload and
menu examples too, as `accept` only filters the picker.

Leave the Fieldset width fix to #87300, and reset the width in the
examples until it lands. Move the preview-only styles to their own
file, write the required and optional markers as other fields do, and
align the docs with the examples.
flex-direction: column;
gap: var(--wpds-dimension-gap-sm);
/* Let the fieldset shrink below its native min-content width. */
min-inline-size: 0;

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.

I considered whether this should be a 0 or auto, and concluded that it only differs in a rather uncommon layout, and 0 seems to be the common reset for fieldsets (e.g. in Bootstrap).

Content min-inline-size: 0 (this PR) min-inline-size: auto
Long filename The fieldset shrinks beside the Upload button and the filename wraps onto two lines inside the container. The fieldset keeps the filename on one line and pushes the Upload button outside the container.
Fixed-width input The fieldset shrinks, but the input keeps its width and extends under the Upload button. The fieldset matches the input's width and the Upload button overflows the container without overlapping.

☝️ The fieldset is outlined in blue, inside a 200px flex row container (dashed).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for comparing them! I agree on 0. It's the usual fieldset reset, and with auto the long-filename case still overflows, which is the case this PR fixes. A fixed-width child overflowing the fieldset seems like the child's job to constrain, so I've kept 0.

ciampo and others added 3 commits November 25, 2026 15:01
Browsers size a fieldset to at least the width of its content. A long
filename or other unbreakable text inside `Fieldset.Root` then makes the
fieldset overflow its container instead of truncating. Reset
`min-inline-size` alongside the border, margin, and padding resets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ciampo
ciampo force-pushed the ui/fieldset-shrink-to-container branch from f07e84e to b3249b4 Compare November 25, 2026 14:02
@ciampo
ciampo enabled auto-merge (squash) November 25, 2026 14:22
@ciampo
ciampo merged commit 3e18d6e into trunk Nov 25, 2026
89 checks passed
@ciampo
ciampo deleted the ui/fieldset-shrink-to-container branch November 25, 2026 14:24
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 25, 2026
ciampo added a commit that referenced this pull request Nov 26, 2026
`Fieldset.Root` now lets its content shrink (#87300), so the examples
no longer need their own reset.
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
* UI Fieldset: Let content wrap or truncate in a narrow container

Browsers size a fieldset to at least the width of its content. A long
filename or other unbreakable text inside `Fieldset.Root` then makes the
fieldset overflow its container instead of truncating. Reset
`min-inline-size` alongside the border, margin, and padding resets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* UI: Add a changelog entry for the Fieldset width fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Fieldset: Clarify when the width fix applies

---------

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
ciampo added a commit that referenced this pull request Nov 30, 2026
The Fieldset fix from #87300 now lets the examples truncate long
filenames, so they no longer need their own min-inline-size reset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ciampo added a commit that referenced this pull request Nov 30, 2026
…ples

Keep "Choose files…" in the panel's header, so it keeps focus when the
first font arrives or the last one is removed. Move focus to the row's
remove button after "Retry", and combine upload results that finish
together into one announcement. Check the file type in the upload and
menu examples too, as `accept` only filters the picker.

Leave the Fieldset width fix to #87300, and reset the width in the
examples until it lands. Move the preview-only styles to their own
file, write the required and optional markers as other fields do, and
align the docs with the examples.
ciampo added a commit that referenced this pull request Nov 30, 2026
`Fieldset.Root` now lets its content shrink (#87300), so the examples
no longer need their own reset.
ciampo added a commit that referenced this pull request Dec 1, 2026
* Storybook: Show how to select local files from a field or menu

* Storybook: Compose file pickers with UI Button, Input, and Menu

* Storybook: Document button, menu, and drop zone file selection

* Storybook: Clarify how to retain a file for form submission

* Storybook: Decline file drags over the disabled picker

* Storybook: Match the file selection examples to the design prototypes

Lay the drop area out as a field: a legend, a surface that opens the
picker, and a description. Show the chosen file as a row with a
thumbnail, the file type and size, and a visible remove button. Add an
example that collects several files, and show the chosen file in the
button and menu examples too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Drop the local fieldset width reset from the file examples

The Fieldset fix from #87300 now lets the examples truncate long
filenames, so they no longer need their own min-inline-size reset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Check the file type in the button example and tidy file rows

Reject files that aren't JSON in the button example, as the drop areas
already do, since `accept` only filters the picker. Cut long filenames
at the end, because the details line already shows the file type, and
middle truncation left a gap before the extension. Give chosen-file rows
a lighter surface than the drop area, and dim the whole prompt when the
drop area is disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Match the drop area to the field design from #86732

Follow the field design shared on the PR: a near-white surface, 12px
block and 16px inline padding, a plus icon with "Add an image", and the
drop hint in the description. The single-file drop area shows the
thumbnail and filename only; rows in a list keep the type and size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Size the drop area like a text input

Give the drop area the height and inline padding of a `@wordpress/ui`
text input, and tighten the padding of chosen-file rows. Note that
removing a file only clears the selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Use even padding around the file thumbnail

Pad the drop area and the chosen-file rows by 8px on every side, so the
thumbnail sits in an even frame and both share the same spacing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Cover uploads, imports, limits, and media sources

Add examples for importing a file as soon as it's chosen, uploading
files with a status in each row, and a panel that accepts files dropped
anywhere in it. Turn the button example into a form that checks a
required file on submit, add file count and size limits to the list of
files, mark optional and required fields, and turn the menu example into
a source menu with a Media Library and an upload item.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Fix focus, announcements, and file checks in the file examples

Keep "Choose files…" in the panel's header, so it keeps focus when the
first font arrives or the last one is removed. Move focus to the row's
remove button after "Retry", and combine upload results that finish
together into one announcement. Check the file type in the upload and
menu examples too, as `accept` only filters the picker.

Leave the Fieldset width fix to #87300, and reset the width in the
examples until it lands. Move the preview-only styles to their own
file, write the required and optional markers as other fields do, and
align the docs with the examples.

* Storybook: Disable remove buttons with their fields and tidy the file docs

Disable the remove button with a disabled drop area, and while a form
imports its file. Clear stale errors after a removal, say how to retry a
failed upload, keep the panel's drop hint once it has files, and show
sizes just under 1 MB in megabytes. Move the import stand-in into a
preview helpers file and use title case for the page heading.

* Storybook: Make file row keys work on any site and tighten the examples

Replace `crypto.randomUUID()`, which needs HTTPS, with a small counter
for row keys. Announce a retried upload, give the announcement its own
timer, and keep the file count check and update on the same list. Style
the Media Library stand-in without the drop area's surface, say what
went wrong when several files are dropped on a single-file field, and
note where focus goes after removing the last row.

* Storybook: Name the drop area's parts and cover whole fields with drop targets

Call the dashed box the drop area and the button that fills it the
picker button, so the docs place the `DropZone` and the remove button
consistently. Let the drop target cover the whole field for several
files and for uploads, so a file dropped on the legend doesn't open in
the tab. Derive the limits copy from the constants, explain why drop
area prompts skip the ellipsis, and drop an unused `noValidate`.

* Storybook: Use WordPress file size units and fix the panel headings

Format sizes like WordPress's `size_format()`, with 1,024 bytes to the
kilobyte, and set the size limit in those units. Announce files as they
start uploading. Make the panel title a heading and the empty state's
title a level below it. Explain that a separate submit suits a form
where people check their choice first, as the Manage Patterns import
form does.

* Storybook: Draw the picker button's focus ring around the whole file row

The remove button sits beside the picker button, so the button's own ring
stopped short of the row. The drop area now draws the ring whenever the
picker button has focus, matching the hover background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Size single-line file fields like inputs

A drop area is now 40px tall, with a 24px thumbnail and a small remove
button spaced like a button in an input's suffix, as in the password
example. File picker surfaces also use the input corner radius.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Show each chosen file on one input-height line

The type and size now sit at the end of the row, after a filename that
is cut off when it's long, so every row and drop area is 40px with a
24px thumbnail and small buttons. While a file uploads, a short progress
bar sits beside its remove button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Draw a hairline inside image thumbnails

A light image was hard to see on a light row. Image thumbnails now have
the same translucent inner stroke as media thumbnails in DataViews.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Use regular text for filenames in file rows

Emphasis marks interactive text. A filename in a row isn't interactive,
so it now uses the regular weight. Text in a picker button stays
emphasized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Nest the thumbnail radius inside the row radius

Thumbnails now use the radius one step smaller than their row, so the
corners nest in every theme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Show upload progress in place of the file details

While a file uploads, its type and size give way to the progress bar and
its name is weaker, so the name keeps most of the row. The details come
back when the upload finishes or fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Make the whole cover image field the drop target

The drop overlay's icon and label didn't fit in a field the height of an
input. The overlay now covers the legend, field and description, as in
the examples for several files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Center the empty state in the fonts panel

EmptyState limits its own width but doesn't center itself, so it sat at
the start of the panel. A centering Stack places it, as on the widget
dashboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Keep filenames visible and flag failed uploads with a badge

A failed row now shows only a high-intent Badge and Retry, and every
filename keeps a few characters before the type, size or status are cut.
Uploaded is plain text, since a finished upload doesn't need attention.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Drop the fieldset width reset from the file examples

`Fieldset.Root` now lets its content shrink (#87300), so the examples
no longer need their own reset.

* Storybook: Show whole filenames in file rows and fix the picker's name

A cut filename can't be read in full on a touch screen, and two files
with the same start look the same. Let the name wrap instead, with a
tighter line height so a wrapped name reads as one item. When the type
and size, or a status and its Retry button, don't fit beside the name,
they move below it together.

The picker button now builds its name from the text it shows, with a
visually hidden "Replace" before it, so the type and size reach
assistive technology. Keep the progress bar on whole pixels so every
bar looks the same thickness, and keep the "Uploaded" note.

* Storybook: Fix announcements, list roles, and long names in file errors

- Queue cancel and retry messages with the upload results, so a
  cancellation made right after adding a file is read last.
- Give each file list an explicit list role. Safari drops it when the
  markers are hidden.
- Let a long filename in an error message wrap, so the page doesn't
  scroll sideways at 320px.

* Storybook: Check file types and pattern files like the real screens

The PNG and JSON fields accept a file by its MIME type or extension,
as their `accept` attribute does. The stand-in importer now requires
the same fields as the Patterns screen, so any other JSON file shows
the error.

* Storybook: Show the preview stylesheet that the file examples import

* Storybook: Pass whether an upload fails instead of counting attempts

Only the first try for a PDF fails, so the caller can say so, and the
upload no longer needs to store its attempt count.

* Storybook: Keep a ref to each row's remove button on its entry

Each entry gets its own ref when it's added, so the list examples no
longer keep a map of buttons and a callback that fills it.

* Storybook: Let the file type and size wrap with the filename

The type comes from the filename, so a long extension could still
make the page scroll sideways.

* Storybook: Say which pattern fields the stand-in importer checks

* Storybook: Show the file icon when an image can't be previewed

Some images, such as HEIC photos, can't be shown in every browser. The
row now falls back to the file icon instead of an empty thumbnail.

* Storybook: Reject the same pattern files as the Patterns screen

The stand-in importer now also rejects a non-string `syncStatus`, and
lets `JSON.parse()` throw to the caller, which already shows the error.

* Storybook: Hide an earlier import confirmation on the next try

* Storybook: Say what MediaUpload passes to its onSelect handler

* Storybook: Hide an earlier import confirmation when the next import starts

* Storybook: Show the preview snackbars below the example

A long confirmation grew upward from the bottom of a fixed frame and
covered the Import button. In the page flow it can't, and the frame
is no longer needed.

* Storybook: Keep the fonts panel's bottom padding

`DropZone` after `Card.Content` made the content a middle section,
which has no bottom padding.

* Storybook: Clear the preview URL when an image can't be shown

* Storybook: Mention MediaUploadCheck and when the limit message shows

* Storybook: Create font entries before updating the list

A state updater can run twice, so it shouldn't create IDs or refs.

* Storybook: Try a preview for a file without a type

A browser leaves the type empty when it can't tell what a file is. An
image then still gets its thumbnail, and any other file falls back to
the file icon.

* Storybook: Fix the comment on chosen-file rows

* Storybook: Say to keep MediaUpload outside the source menu

* Storybook: Keep focus when an imported file's row goes away

If the remove button has focus when the import finishes, move focus to
"Choose file…" before the row is removed.

* Storybook: Point to MediaUpload's docs and limit it to images

* Storybook: Share the file error message between the examples

Each example repeated the same live region and `ValidityIndicator`.
`FilePickerError` keeps the region mounted, so a new message is still
announced.

* Storybook: Use interactive tokens for the drop area

The drop area is a control, and surface tokens aren't for clickable
parts. It now uses the neutral interactive tokens, like an input
without a border, with matching hover and disabled states. The rows
show chosen files, so they keep the surface tokens.

* Storybook: Finish moving the file controls to interactive tokens

- Compare the drop area with an outline Button in the docs, which uses
  the same tokens, and drop a sentence that no longer holds.
- Gray out a full or disabled drop area in forced-colors mode, as
  Button does, since it stays focusable.
- Give text inside a picker button the button's weaker color.
- Give the stand-in Media Library items their padding back and the same
  interactive tokens.

* Storybook: Add temporary stories comparing file row layouts

Compare two layouts for long filenames with the current one: the type
and size always below the name, or always on the name's first line with
only the name wrapping. Remove the stories and the `layout` prop once a
layout is chosen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Stack file details below the name, with a larger thumbnail

Every file row now has one layout: a 40px thumbnail, the name, and the
type and size on a line below it. The thumbnail, the first line of the
name, and the remove button line up at the top. A long name wraps and
makes only its own row taller.

Remove the temporary stories that compared layouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Move the panel's file button into the empty state

The button in the card's header pushed the title out of place. Put it in
the empty state's actions, and below the list once fonts are added.

The button now moves when the first font arrives or the last one goes,
so render the change with `flushSync()` and focus the new button when
the old one had focus.

* Storybook: Name focused buttons correctly and refocus after a failed import

Removing a cover image and retrying an upload moved focus before the
change rendered, so the focused button still had its old name. Render
the change with `flushSync()` first.

When an import fails because the file can't be used, move focus to
"Choose file…", as for any invalid field. Note in the docs that the
server still checks every file.

* Storybook: Render every change before moving focus, and isolate filenames

Each example decided on its own whether a change could rename the
button that gets focus, and several missed one: the error description
after an empty submit, the disabled state after a failed import, and
"Add files" after the last removal. Render the change with `flushSync()`
before every `focus()` call, and state that rule once in the checklist.

Wrap filenames in `<bdi>`, so a name such as `123 - report.png` keeps
its order on a right-to-left page.

Note in the docs that the picker button doesn't repeat the fieldset's
description, which the group already exposes.

* Storybook: Keep focus where people moved it during an import

A failed import moved focus to "Choose file…" even when people had moved
on to another field while it ran. Move focus only if it's still where it
was on submit; the live region still announces the error.

In the docs, describe how `Fieldset` links its description instead of
what screen readers do with it, say that a rejected replacement keeps
the previous file, and drop a sentence about narrow upload rows that no
longer matched the stacked layout.

* Storybook: Describe pickers with their field's requirements, and keep errors

The fieldset's description holds the picker's requirements, such as the
accepted types and limits, but it was linked only to the group. Give it
an `id`, and list it in the picker button's `aria-describedby` before
the error.

Removing a file cleared the error, so the names of rejected files went
away while people made room for them. Keep an error until the next file
is added.

Wrap filenames in error messages in Unicode isolates, as `<bdi>` does
in the rows, so they keep their order on a right-to-left page.

* Storybook: Keep the font formats in view, and isolate filenames in labels

Adding the first font replaced the only text that listed the supported
formats. List them below the button too, and link the text to the
button in both states.

`IconButton` shows its label in a tooltip, so a remove button's label
mixed its filename with "Remove" on a right-to-left page. Isolate
filenames in every string that is shown, as in errors.

* Storybook: Check a pattern file's size before reading it

The checklist says to check every file's size, but both import examples
read the whole file first. Check it against a 1 MB limit before the
import reads it, and state the limit in the field's description.

Note in the docs that `speak()` drops text that looks like an HTML tag,
such as `<draft>` in a filename.

* Storybook: State the import's size limit before a file is chosen

The import-on-choose example showed its 1 MB limit only after rejecting
a file. Show it below the button and link it with `aria-describedby`.

Reword the checklist so it asks for each field's own rules, as the
examples check type everywhere and size or count only where a field
limits them.

* Storybook: Say that the remove button's column isn't part of the picker button

* Storybook: Tell a bad pattern file from a failed request, and fix hover contrast

Both import examples treated every failure as a bad file, so a failed
request would ask for another file and move focus to the picker. Split
the stand-in into `readPattern()` and `savePattern()`: a file that can't
be read or isn't a pattern asks for another file, and a failed request
keeps the file and asks people to try again.

On hover, the picker's weaker text kept its resting color on the darker
background, at 4.32:1. Use the matching `-active` token.

Raise the preview snackbars' specificity with their own class, not with
`.components-snackbar-list`, which belongs to the component.

* Storybook: Align the picker's tokens with Button and Text, and clear stale errors

The picker said it used an outline `Button`'s tokens, but only switched
background and stroke, and only on hover. Switch the foreground too, on
hover, press, and focus, as `Button` does. Disabled weak text now uses
its own `-weak-disabled` role.

Filenames overrode `Text`'s `body-md` line height with `line-height-xs`,
a pairing the type scale doesn't define. Keep `body-md`, and close the
gap to the details below, so a one-line row keeps its height.

Removing the chosen file from a single-file field now clears its error
too, as the error was about that file. Lists still keep the names of
rejected files while people make room. Import on choose keeps no file,
so its failed-request error says to choose the file again.

---------

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: lucyneb <lucybbn@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] UI /packages/ui [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants