-
Notifications
You must be signed in to change notification settings - Fork 756
Description
Migrated from WICG/spatial-navigation#129
Originally created by @hugoholgersson on Fri, 02 Nov 2018 07:26:42 GMT
Even when the focused element F is off the screen, for example after F.focus({preventScroll: true}), spatnav uses F as starting point for distance calculations.
Why is this a problem? It gives an unpredictable user experience:
Imagine F being off-screen, above the visual viewport. If the user goes up, she probably wants to search the viewport for candidates from the bottom-most edge. (This is how spatnav would search a focused scroller.) Instead, the current spec calculates distances from the scrolled out F. The closest candidate is the focusable closest to F's position - a position the user can't see.
In Chrome we've solved this by skipping off-screen starting points: when F is off-screen, we search from an edge of the first visible enclosing container of F. I've updated https://bit.ly/snav2, my vision for spatnav in Chrome, to cover this case.