From 67e2a8fb797a525ae80782c10c0ab030da0367a0 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 30 Sep 2019 11:32:27 +0300 Subject: [PATCH] fix: left menu item before group is not highligted fixes #1033 --- src/services/MenuStore.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/services/MenuStore.ts b/src/services/MenuStore.ts index f775070b4e..16119e7e6c 100644 --- a/src/services/MenuStore.ts +++ b/src/services/MenuStore.ts @@ -116,7 +116,7 @@ export class MenuStore { } if (isScrolledDown) { - const el = this.getElementAt(itemIdx + 1); + const el = this.getElementAtOrFirstChild(itemIdx + 1); if (this.scroll.isElementBellow(el)) { break; } @@ -163,6 +163,18 @@ export class MenuStore { return (item && querySelector(`[${SECTION_ATTR}="${item.id}"]`)) || null; } + /** + * get section/operation DOM Node related to the item or if it is group item, returns first item of the group + * @param idx item absolute index + */ + getElementAtOrFirstChild(idx: number): Element | null { + let item = this.flatItems[idx]; + if (item && item.type === 'group') { + item = item.items[0]; + } + return (item && querySelector(`[${SECTION_ATTR}="${item.id}"]`)) || null; + } + /** * current active item */