fix: Fix menu scrolling. (#8881)

This commit is contained in:
Aaron Dodson
2025-04-14 13:56:46 -07:00
committed by GitHub
parent 98cf5cb8ee
commit e45471d6f4
3 changed files with 14 additions and 18 deletions

View File

@@ -258,11 +258,10 @@ export class Menu {
// Bring the highlighted item into view. This has no effect if the menu is
// not scrollable.
const menuElement = this.getElement();
const scrollingParent = menuElement?.parentElement;
const menuItemElement = item.getElement();
if (!scrollingParent || !menuItemElement) return;
if (!menuElement || !menuItemElement) return;
style.scrollIntoContainerView(menuItemElement, scrollingParent);
style.scrollIntoContainerView(menuItemElement, menuElement);
aria.setState(menuElement, aria.State.ACTIVEDESCENDANT, item.getId());
}
}