don't override section activation if section if open

This commit is contained in:
zadam 2021-05-29 14:25:05 +02:00
parent ef4bc13dd1
commit 65c3bcb565

View File

@ -155,7 +155,7 @@ export default class CollapsibleSectionContainer extends NoteContextAwareWidget
this.lastActiveComponentId = sectionComponentId; this.lastActiveComponentId = sectionComponentId;
const activeChild = this.getActiveChild(); const activeChild = this.getActiveSectionWidget();
if (activeChild) { if (activeChild) {
activeChild.handleEvent('noteSwitched', {noteContext: this.noteContext, notePath: this.notePath}); activeChild.handleEvent('noteSwitched', {noteContext: this.noteContext, notePath: this.notePath});
@ -193,7 +193,7 @@ export default class CollapsibleSectionContainer extends NoteContextAwareWidget
this.$titleContainer.append($sectionTitle); this.$titleContainer.append($sectionTitle);
this.$titleContainer.append('<div class="section-title section-title-empty">'); this.$titleContainer.append('<div class="section-title section-title-empty">');
if (ret.activate && !$sectionToActivate && !noExplicitActivation) { if (ret.activate && !this.lastActiveComponentId && !$sectionToActivate && !noExplicitActivation) {
$sectionToActivate = $sectionTitle; $sectionToActivate = $sectionTitle;
} }
@ -226,11 +226,15 @@ export default class CollapsibleSectionContainer extends NoteContextAwareWidget
await super.handleEventInChildren('setNoteContext', data); await super.handleEventInChildren('setNoteContext', data);
} }
else { else {
const activeChild = this.getActiveChild(); const activeSectionWidget = this.getActiveSectionWidget();
// forward events only to active section, inactive ones don't need to be updated // forward events only to active section, inactive ones don't need to be updated
if (activeChild) { if (activeSectionWidget) {
await activeChild.handleEvent(name, data); await activeSectionWidget.handleEvent(name, data);
}
for (const buttonWidget of this.buttonWidgets) {
await buttonWidget.handleEvent(name, data);
} }
} }
} }
@ -245,7 +249,7 @@ export default class CollapsibleSectionContainer extends NoteContextAwareWidget
} }
} }
getActiveChild() { getActiveSectionWidget() {
return this.children.find(ch => ch.componentId === this.lastActiveComponentId) return this.sectionWidgets.find(ch => ch.componentId === this.lastActiveComponentId)
} }
} }