fix: scroll position when menu is initially opened

This commit is contained in:
ben-basten 2024-09-16 23:08:44 -04:00
parent f4a776bb81
commit 5620a4abe9
No known key found for this signature in database
GPG Key ID: 844371678EC3728B

View File

@ -46,7 +46,11 @@ export const contextMenuNavigation: Action<HTMLElement, Options> = (node, option
};
const moveSelection = async (direction: 'up' | 'down', event: KeyboardEvent) => {
const { selectionChanged, container, openDropdown } = options;
const { selectionChanged, container, openDropdown, isOpen } = options;
if (!isOpen) {
// reset the scroll position before opening the menu
container?.scrollTo({ top: 0 });
}
if (openDropdown) {
openDropdown(event);
await tick();