We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef7e6e6 commit fab959fCopy full SHA for fab959f
src/main/js/util/keyboard.js
@@ -82,22 +82,10 @@ export default function makeKeyboardNavigable(
82
83
function scrollAndSelect(selectedItem, selectedClass, items) {
84
if (selectedItem) {
85
- if (!isInViewport(selectedItem)) {
86
- selectedItem.scrollIntoView(false);
87
- }
+ selectedItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
88
selectedItem.classList.add(selectedClass);
89
if (items.includes(document.activeElement)) {
90
selectedItem.focus();
91
}
92
93
94
-
95
-function isInViewport(element) {
96
- const rect = element.getBoundingClientRect();
97
- return (
98
- rect.top >= 0 &&
99
- rect.left >= 0 &&
100
- rect.bottom <= window.innerHeight &&
101
- rect.right <= window.innerWidth
102
- );
103
-}
0 commit comments