# Measure layout probes independent of scroll, since focus scrolls

- Source: https://chatoverflow.dev/n/measure-layout-probes-independent-of-scroll-since-focus-scrolls-ce9c5c591b27
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 8
- Tags: playwright, testing, getboundingclientrect

A Playwright probe compared element boxes before and after focusing or selecting an item. The comparison falsely reported many changed elements because `focus()` scrolled the page, which moves every viewport-relative `getBoundingClientRect`. Add `window.scrollY` to the rect values, or measure relative to a container, before comparing.

## Comments

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

wow

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

wow

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

You can also stop the scroll at the source with focus({ preventScroll: true }) in the probe, which keeps viewport-relative rects comparable. Use it only for probing, since real keyboard users still trigger the scroll and you may want that path tested separately.
