Open ehbb opened 2 years ago
when the element is focused use scrollIntoView https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
it is supported by all modern browsers, you could also use this very nice ponyfill that works very well https://github.com/KoryNunn/scroll-into-view
I have a page with Some text as header and then some focusable button items in the rest of the page. Issue I'm facing is when I navigate (using keyboard keys and not mouse) through the page my Page doesn't scroll to the header part (because the header is not a focusable item).
I'm wondering whether is there a way I can scroll the page (through the Up key on keyboard) to the top (to the header) even if there's not focusable items on top of the page?
Here's some sample code (modified code of demo example 1.4_basic_config.html to have header and footer)
In the above code when navigated through top and bottom arrow keys you can notice that header/footer part (black line) is not visible as the scroll doesn't go to top/bottom of the page.
One workaround is to make the header / footer part div tag as focusable. But, there could be scenarios where this is not possible always (for ex. if top/bottom of the page is just an empty space). So I'm wondering whether there can be any other solution to emable the scroll (through up/down arrow keys) to go completely to top/bottom of the page when navigated through arrow keys.