add jsdoc for menu.collapse and provide ability to opt-out of updating the scroll position if needed

This commit is contained in:
Braden Napier 2019-03-18 21:14:12 -07:00
parent 574c1c15b9
commit e304e79290

View File

@ -220,8 +220,16 @@ export class MenuStore {
}
}
collapse(item: IMenuItem) {
/**
* Collapsed the given item without collapsing all parent items like
* `deactivate` does. This is used to close a group item when clicked
* if it is already expanded.
*
* @param {IMenuItem} item
*/
collapse(item: IMenuItem, updateScrollPosition: boolean = true) {
this.activate(item.parent, true, true, false);
if (updateScrollPosition) {
const activeItem = this.activeItem;
if (item.items.length > 0) {
this.scroll.scrollIntoView(this.getElementAt(item.absoluteIdx || -1));
@ -232,6 +240,7 @@ export class MenuStore {
this.scroll.scrollIntoView(this.getElementAt(activeItem.absoluteIdx || -1));
}
}
}
/**
* makes item and all the parents not active