Skip to content

[6.x] Forms 2: Stop the opinion scale overflowing narrow fields - #16165

Merged
jaygeorge merged 8 commits into
6.xfrom
16165-opinion-scale-overflow
Dec 3, 2026
Merged

jaygeorge merged 8 commits into
6.xfrom
16165-opinion-scale-overflow

Conversation

@jaygeorge

@jaygeorge jaygeorge commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

image

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:

  • It splits into two even rows (6 + 5 for 0–10), or wraps freely if even two rows don't fit.
  • The labels become a small legend that pairs each one with its value (0 Not likely, 5 Maybe, 10 Very 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

image

How to Reproduce

  1. Add an opinion scale to a form, with low, middle and high labels, and set its width to 1/2 or 1/3.
  2. Open the form builder.
  3. The scale runs past its field.

- 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
- 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
@jaygeorge
jaygeorge enabled auto-merge (squash) December 3, 2026 12:55
@jaygeorge
jaygeorge merged commit 54a1ea3 into 6.x Dec 3, 2026
64 checks passed
@jaygeorge
jaygeorge deleted the 16165-opinion-scale-overflow branch December 3, 2026 12:57
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.

Form builder: Opinion Scale overflows the canvas

1 participant