mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
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:
@@ -48,12 +48,12 @@ export function MegaMenuItem({ link, activeItem, level = 0, onClick }: Props) {
|
|||||||
|
|
||||||
// scroll active element into center if it's offscreen
|
// scroll active element into center if it's offscreen
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (menuIsDocked && isActive && item.current && isElementOffscreen(item.current)) {
|
if (isActive && item.current && isElementOffscreen(item.current)) {
|
||||||
item.current.scrollIntoView({
|
item.current.scrollIntoView({
|
||||||
block: 'center',
|
block: 'center',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [isActive, menuIsDocked]);
|
}, [isActive]);
|
||||||
|
|
||||||
if (!link.url) {
|
if (!link.url) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user