From 0d8a97a7815f5ad1086aab0dafe6a1d1a4e10535 Mon Sep 17 00:00:00 2001 From: rogup Date: Fri, 10 May 2024 17:43:01 +0100 Subject: [PATCH] Fix forward button behaviour and show results panel when moving through history --- src/map-app/app/presenter/sidebar/base.ts | 7 ++++++- src/map-app/undo-stack.ts | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/map-app/app/presenter/sidebar/base.ts b/src/map-app/app/presenter/sidebar/base.ts index 3de55e08..8bbdc4e4 100644 --- a/src/map-app/app/presenter/sidebar/base.ts +++ b/src/map-app/app/presenter/sidebar/base.ts @@ -3,6 +3,7 @@ import { BasePresenter }from '../base'; import { BaseSidebarView } from '../../view/sidebar/base'; import { SidebarPresenter } from '../sidebar'; import { Initiative } from '../../model/initiative'; +import { canDisplayExpandedSidebar } from '../../../utils'; export interface NavigationCallback { disabled: boolean; @@ -21,8 +22,12 @@ export abstract class BaseSidebarPresenter extends BasePresenter { * If the sidebar wants to do something more than to get its view to refresh when the history * buttons have been used, then it should override this definition with its own. */ - historyButtonsUsed(): void { + historyButtonsUsed(): void { this.view.refresh(false); + + // Show the results pane again, since there have been changes + if (canDisplayExpandedSidebar()) // on smaller screens, wait until user clicks Apply Filters + EventBus.Sidebar.showInitiativeList.pub(); } deselectInitiatives(): void { diff --git a/src/map-app/undo-stack.ts b/src/map-app/undo-stack.ts index 2d9b73dd..a9370a98 100644 --- a/src/map-app/undo-stack.ts +++ b/src/map-app/undo-stack.ts @@ -39,7 +39,10 @@ export class WalkableStack1 { assert(this.storage.length > this.index, "storage should always have the initial state element"); this.index += 1; - this.storage[this.index] = obj; // sets storage.length to index+1 + this.storage[this.index] = obj; + + // remove later items from the stack + this.storage.length = this.index + 1; } // Get the current item in the stack