Skip to content

[6.x] Speed up button groups on large entries - #15765

Merged
duncanmcclean merged 1 commit into
6.xfrom
button-group-overflow
Nov 2, 2026
Merged

duncanmcclean merged 1 commit into
6.xfrom
button-group-overflow

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request speeds up loading entries with lots of Button Group fields.

Button groups check whether their buttons have wrapped onto a second line, so they can stack vertically instead. Every group checked once when it mounted, then again when its ResizeObserver first fired. Each check toggled a "measuring" state, waited a tick, then read offsetTop, which forces the browser to recalculate styles. On a customer's entry with 376 button groups, that added up to ~300 forced style recalculations, costing ~3.5 seconds while the entry loads.

This PR fixes it by only reading layout inside the ResizeObserver callback, where the browser has just calculated it anyway, so it's free. The full measurement only runs when the buttons have wrapped, or the group is already stacked.

On the customer's entry (43 Bard fields, lots of sets), time until all editors are loaded went from ~9.4s to ~4.9s, and style recalculation went from ~5.4s to ~1.2s.

I've added a browser test which covers groups stacking and unstacking. It passes before and after this change.

Related: #13385

@duncanmcclean
duncanmcclean merged commit 153c1f4 into 6.x Nov 2, 2026
65 checks passed
@duncanmcclean
duncanmcclean deleted the button-group-overflow branch November 2, 2026 17:24
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