From 8817b036824fcb7617c784091c5e63c2e255ceb4 Mon Sep 17 00:00:00 2001 From: Mikael Boff Date: Mon, 22 Feb 2021 19:43:47 -0300 Subject: [PATCH] fix(scroll): Scroll into view of active menu item when navigating with arrows --- .../ngx-contextmenu/src/lib/contextMenuContent.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/ngx-contextmenu/src/lib/contextMenuContent.component.ts b/projects/ngx-contextmenu/src/lib/contextMenuContent.component.ts index a27e1c2..0222af1 100644 --- a/projects/ngx-contextmenu/src/lib/contextMenuContent.component.ts +++ b/projects/ngx-contextmenu/src/lib/contextMenuContent.component.ts @@ -213,6 +213,11 @@ export class ContextMenuContentComponent return; } this._keyManager.onKeydown(event); + const activeItemIndex = this._keyManager.activeItemIndex; + const menuItemElement = this.menuItemElements.toArray()[activeItemIndex]; + if (menuItemElement) { + menuItemElement.nativeElement.scrollIntoViewIfNeeded(); + } } @HostListener('window:keydown.ArrowRight', ['$event'])