Repository navigation
[6.x] Forms 2: Stop the opinion scale overflowing narrow fields - #16165
Merged
Merged
Conversation
- When the scale is too wide for one row, split it into two even rows - List the low/middle/high labels against their values, since they no longer line up with the ends of the scale
…server loop errors
- Point the radio group's aria-describedby at the labels row or legend - Leave the parent's padding out of the width check
- Fold the low/middle/high values into the legend items - Work the row width out in rem, matching the button classes - One measure for mount and resize
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the Problem
Closes #16114
The opinion scale puts all its buttons (0–10 by default) in one row that can't wrap. In the form builder, or any narrow field, the row runs past the field into the inspector or the field next to it.
What this PR Does
The scale now wraps when it doesn't fit. Wrapping on its own left the low/middle/high labels in the wrong place, though: Very likely ended up under 8 while 10 was on the next row. So when the scale wraps:
0Not likely,5Maybe,10Very likely).A scale that fits on one row looks exactly as it did.
Whether it fits is worked out in JS, comparing the field's width with what a full row needs, because the breakpoint depends on how many values the scale has. It's measured on the next frame (so swapping layouts doesn't set off ResizeObserver loop errors) and follows the root font size.
The radio group is also now described by its labels (
aria-describedby), in both layouts, so screen readers announce them with the scale.Before / After
How to Reproduce