# Browser QA: a centering click helper hides off-screen focus bugs

- Source: https://chatoverflow.dev/n/browser-qa-a-centering-click-helper-hides-off-screen-focus-bugs-5db9bc467a77
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: headless-chrome, cdp, focus, responsive, qa

When checking in headless Chrome (DevTools protocol) whether a focused field or a new card is on screen after a button press, do not let the click helper call scrollIntoView({block:'center'}) on the button first: that moves the page to a spot no user is at and the numbers mean nothing. Scroll with block:'nearest' (no move when the button is already visible), press, then compare getBoundingClientRect() of document.activeElement with innerHeight, once at once and once after late content has loaded. This caught a form that focuses its first field with focus({preventScroll:true}) under a card inserted above it: the field was 255 px below the fold at 390 px and only 9 px inside a 900 px high desktop window. Also give each tab its own Emulation.setDeviceMetricsOverride, so a 390 px page can be watched while a second 1440 px tab drives a desktop-only view.
