fix: fixes issue where toggled-off panes would reappear after making selection

This commit is contained in:
Mo
2022-12-05 06:55:39 -06:00
parent f3203e2e80
commit a6a0d615c5

View File

@@ -32,6 +32,9 @@ export class PaneController extends AbstractViewController {
currentItemsPanelWidth = 0 currentItemsPanelWidth = 0
focusModeEnabled = false focusModeEnabled = false
listPaneExplicitelyCollapsed = false
navigationPaneExplicitelyCollapsed = false
constructor(application: WebApplication, eventBus: InternalEventBus) { constructor(application: WebApplication, eventBus: InternalEventBus) {
super(application, eventBus) super(application, eventBus)
@@ -150,7 +153,17 @@ export class PaneController extends AbstractViewController {
setPaneLayout = (layout: PaneLayout) => { setPaneLayout = (layout: PaneLayout) => {
log(LoggingDomain.Panes, 'Set pane layout', layout) log(LoggingDomain.Panes, 'Set pane layout', layout)
this.replacePanes(panesForLayout(layout, this.application)) const panes = panesForLayout(layout, this.application)
if (panes.includes(AppPaneId.Items) && this.listPaneExplicitelyCollapsed) {
removeFromArray(panes, AppPaneId.Items)
}
if (panes.includes(AppPaneId.Navigation) && this.navigationPaneExplicitelyCollapsed) {
removeFromArray(panes, AppPaneId.Navigation)
}
this.replacePanes(panes)
} }
replacePanes = (panes: AppPaneId[]) => { replacePanes = (panes: AppPaneId[]) => {
@@ -211,20 +224,24 @@ export class PaneController extends AbstractViewController {
toggleListPane = () => { toggleListPane = () => {
if (this.panes.includes(AppPaneId.Items)) { if (this.panes.includes(AppPaneId.Items)) {
this.removePane(AppPaneId.Items) this.removePane(AppPaneId.Items)
this.listPaneExplicitelyCollapsed = true
} else { } else {
if (this.panes.includes(AppPaneId.Navigation)) { if (this.panes.includes(AppPaneId.Navigation)) {
this.insertPaneAtIndex(AppPaneId.Items, 1) this.insertPaneAtIndex(AppPaneId.Items, 1)
} else { } else {
this.insertPaneAtIndex(AppPaneId.Items, 0) this.insertPaneAtIndex(AppPaneId.Items, 0)
} }
this.listPaneExplicitelyCollapsed = false
} }
} }
toggleNavigationPane = () => { toggleNavigationPane = () => {
if (this.panes.includes(AppPaneId.Navigation)) { if (this.panes.includes(AppPaneId.Navigation)) {
this.removePane(AppPaneId.Navigation) this.removePane(AppPaneId.Navigation)
this.navigationPaneExplicitelyCollapsed = true
} else { } else {
this.insertPaneAtIndex(AppPaneId.Navigation, 0) this.insertPaneAtIndex(AppPaneId.Navigation, 0)
this.navigationPaneExplicitelyCollapsed = false
} }
} }