mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 14:14:56 +03:00
fix: 2-level collapsible collapse handling
This commit is contained in:
parent
405e26ad79
commit
574c1c15b9
|
@ -71,6 +71,7 @@ tags:
|
||||||
SubItem Two Description!
|
SubItem Two Description!
|
||||||
x-tagGroups:
|
x-tagGroups:
|
||||||
- name: General
|
- name: General
|
||||||
|
collapsible: true
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
- store
|
- store
|
||||||
|
@ -82,7 +83,6 @@ x-tagGroups:
|
||||||
tags:
|
tags:
|
||||||
- SubItem One
|
- SubItem One
|
||||||
- SubItem Two
|
- SubItem Two
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/pet:
|
/pet:
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
@ -193,6 +193,7 @@ export class MenuStore {
|
||||||
item: IMenuItem | undefined,
|
item: IMenuItem | undefined,
|
||||||
updateLocation: boolean = true,
|
updateLocation: boolean = true,
|
||||||
rewriteHistory: boolean = false,
|
rewriteHistory: boolean = false,
|
||||||
|
activateFirstChild: boolean = true,
|
||||||
) {
|
) {
|
||||||
if ((this.activeItem && this.activeItem.id) === (item && item.id)) {
|
if ((this.activeItem && this.activeItem.id) === (item && item.id)) {
|
||||||
return;
|
return;
|
||||||
|
@ -211,7 +212,7 @@ export class MenuStore {
|
||||||
this.history.replace(item.id, rewriteHistory);
|
this.history.replace(item.id, rewriteHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.type === 'group') {
|
if (item.type === 'group' && activateFirstChild) {
|
||||||
this.activate(item.items[0], updateLocation, rewriteHistory);
|
this.activate(item.items[0], updateLocation, rewriteHistory);
|
||||||
} else {
|
} else {
|
||||||
item.activate();
|
item.activate();
|
||||||
|
@ -220,14 +221,13 @@ export class MenuStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse(item: IMenuItem) {
|
collapse(item: IMenuItem) {
|
||||||
this.activate(item.parent, true, true);
|
this.activate(item.parent, true, true, false);
|
||||||
const activeItem = this.activeItem;
|
const activeItem = this.activeItem;
|
||||||
if (!activeItem) {
|
if (item.items.length > 0) {
|
||||||
if (item.items.length > 0) {
|
this.scroll.scrollIntoView(this.getElementAt(item.absoluteIdx || -1));
|
||||||
this.scroll.scrollIntoView(this.getElementAt(item.absoluteIdx || -1));
|
} else if (!activeItem) {
|
||||||
} else if (item.parent && item.parent.type === 'group') {
|
const parentIdx = (item.parent && item.parent.absoluteIdx) || -1;
|
||||||
this.scroll.scrollIntoView(this.getElementAt(item.parent.absoluteIdx || -1));
|
this.scroll.scrollIntoView(this.getElementAt(parentIdx));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.scroll.scrollIntoView(this.getElementAt(activeItem.absoluteIdx || -1));
|
this.scroll.scrollIntoView(this.getElementAt(activeItem.absoluteIdx || -1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user