A responsive layout may look correct while open and while collapsed, yet feel wrong in the movement between those states. Learn how visual comparisons and browser measurements expose the gap.

A sidebar collapse should either give content more usable space or make the interface quieter. It should not move the page away from its own navigation. This class of responsive layout bug is easy to miss because the open and collapsed states can each look reasonable in isolation.
The remedy is to test the relationship between states, not only a screenshot of each one. Define the visual rule in plain language, compare the real browser output at representative widths and make the important measurement executable.
Imagine a navigation rail that shrinks from labels and icons to icons alone. Beside it sits a page column with a maximum width and automatic horizontal margins. When the rail frees space, the column may already be at its maximum. Instead of becoming wider, it stays the same width and the automatic margins absorb the spare room.
The result can be a larger gap between navigation and content. The page did move, just not in the way the product intended. This is not a CSS failure. It is an unspoken decision about where the freed width should go.
Cumulative Layout Shift measures unexpected visual movement and is useful because unexpected shifts can make people lose their place or click the wrong control. Google’s CLS guidance explains those user effects. But a movement immediately following a click may be excluded because the person initiated it.
That is sensible for the metric and still leaves work for the team. A user-requested transition can be intentional yet visually wrong. Product-specific quality rules need product-specific testing.
Avoid testing a CSS class when the requirement is visual. A class can be present while a maximum width, scrollbar or parent layout defeats the intended geometry. In a real browser, measure the bounding rectangles of the elements that express the rule.
Visual comparison is particularly good at revealing a gap that maths alone may not communicate. Playwright can generate a reference screenshot and compare later runs against it. Capture the open state, collapsed state and any hover or temporary expansion state at the same viewport widths.
Keep the screenshot review disciplined. A changed image tells you that something differs, not whether it is wrong. Pair it with a named rule such as “the page heading must stay aligned when the rail changes mode”. That gives reviewers a reasoned decision rather than an aesthetic guess.
A side rail often creates a three-way trade-off: content can stay still, the open rail can avoid covering it, or collapsing can reclaim every pixel. At some widths, one layout cannot deliver all three. Make the trade-off visible in a small decision table, then decide which cost is acceptable for the people using that screen.
For an operational dashboard, keeping a person’s place may matter more than using every spare pixel. For a dense reporting screen, extra room may be worth a carefully managed shift. Neither answer is universal. The important thing is that the behaviour is chosen and tested.
A responsive interface is not complete when it changes size without overflowing. It is complete when its change preserves the relationship people rely on: navigation stays connected to content, controls remain reachable and the interface does not make a person find their place again.
Ready when you are