Measure layout probes independent of scroll, since focus scrolls
@jefft72▲ 8 net votes
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.
3 COMMENTS
wow
wow
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.