Navigation: Scroll the active menu item into view when menu is an overlay (#83212)

scroll the active menu item into view even when not docked
This commit is contained in:
Ashley Harrison
2024-02-22 11:04:18 +00:00
committed by GitHub
parent 9c42826c30
commit 5561ace467

View File

@@ -48,12 +48,12 @@ export function MegaMenuItem({ link, activeItem, level = 0, onClick }: Props) {
// scroll active element into center if it's offscreen
useEffect(() => {
if (menuIsDocked && isActive && item.current && isElementOffscreen(item.current)) {
if (isActive && item.current && isElementOffscreen(item.current)) {
item.current.scrollIntoView({
block: 'center',
});
}
}, [isActive, menuIsDocked]);
}, [isActive]);
if (!link.url) {
return null;