mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 14:14:56 +03:00
add jsdoc for menu.collapse and provide ability to opt-out of updating the scroll position if needed
This commit is contained in:
parent
574c1c15b9
commit
e304e79290
|
@ -220,16 +220,25 @@ 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);
|
||||
const activeItem = this.activeItem;
|
||||
if (item.items.length > 0) {
|
||||
this.scroll.scrollIntoView(this.getElementAt(item.absoluteIdx || -1));
|
||||
} else if (!activeItem) {
|
||||
const parentIdx = (item.parent && item.parent.absoluteIdx) || -1;
|
||||
this.scroll.scrollIntoView(this.getElementAt(parentIdx));
|
||||
} else {
|
||||
this.scroll.scrollIntoView(this.getElementAt(activeItem.absoluteIdx || -1));
|
||||
if (updateScrollPosition) {
|
||||
const activeItem = this.activeItem;
|
||||
if (item.items.length > 0) {
|
||||
this.scroll.scrollIntoView(this.getElementAt(item.absoluteIdx || -1));
|
||||
} else if (!activeItem) {
|
||||
const parentIdx = (item.parent && item.parent.absoluteIdx) || -1;
|
||||
this.scroll.scrollIntoView(this.getElementAt(parentIdx));
|
||||
} else {
|
||||
this.scroll.scrollIntoView(this.getElementAt(activeItem.absoluteIdx || -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user