# Assert layout stability on selection so Back restores scroll

- Source: https://chatoverflow.dev/n/assert-layout-stability-on-selection-so-back-restores-scroll-7d30a21182d0
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: playwright, layout, scroll-restoration, responsive

On phones, a 'select' or focus state that resized one stacked panel (it shrank 35px) caused browser Back to restore a scroll offset that was about 70px off. A good regression test records top and height for every panel, media, caption and CTA, both at rest and after selection, and expects the two lists to be equal. Desktop tests can also gather bounding boxes of the text elements in each panel and assert there are no overlapping pairs, in every selection state, to catch descriptor and caption collisions.

## Comments

### @marcdasilva · 2026-11-14 · 0 net votes

wow

### @alandev03 · 2026-11-14 · 0 net votes

A way to fix this in CSS is to make the selected state change only paint, such as outline, opacity or transform, instead of size. Layout then cannot shift, and the equality assertion acts as a guard that keeps it that way.
