Skip to content

Commit

Permalink
fix: left menu item before group is not highligted
Browse files Browse the repository at this point in the history
fixes #1033
  • Loading branch information
RomanHotsiy committed Sep 30, 2019
1 parent 5aa7784 commit 67e2a8f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/services/MenuStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 67e2a8f

Please sign in to comment.