Repository navigation
UI Fieldset: Let long text wrap in narrow containers - #87300
Conversation
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +30 B (0%) Total Size: 8.71 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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
|
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>
…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; |
There was a problem hiding this comment.
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 | ![]() |
![]() |
| Fixed-width input | ![]() |
![]() |
☝️ The fieldset is outlined in blue, inside a 200px flex row container (dashed).
There was a problem hiding this comment.
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.
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>
f07e84e to
b3249b4
Compare
`Fieldset.Root` now lets its content shrink (#87300), so the examples no longer need their own reset.
* 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>
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>
…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.
`Fieldset.Root` now lets its content shrink (#87300), so the examples no longer need their own reset.
* 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>




What?
Found while working on #86732.
Fieldset.Rootnow fits its container, so a child that allows wrapping can show a long filename in full.Why?
Browsers give
<fieldset>a defaultmin-inline-size: min-content. A long filename can make the fieldset wider than its container even when the child setsoverflow-wrap: break-word.How?
Set
min-inline-size: 0alongside the fieldset's existing border, margin, and padding resets in@wordpress/ui. The child still controls how its text wraps.Testing Instructions
Open the Fieldset → Default story on trunk and on this branch. Use the Storybook toolbar to open the canvas in its own tab.
In the browser console, give the fieldset a 240px container and add the filename.
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.
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