Skip to content

Commit

Permalink
fix(taskDetailPanel): prevent back when open
Browse files Browse the repository at this point in the history
Use `window.history` to keep the panel as another history state.
When the panel is destroyed the history entry is deleted.
  • Loading branch information
benpbo authored and johannesjo committed Jan 31, 2025
1 parent a22e255 commit 66790a4
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
input,
LOCALE_ID,
OnDestroy,
OnInit,
viewChild,
viewChildren,
} from '@angular/core';
Expand Down Expand Up @@ -124,7 +125,7 @@ interface IssueDataAndType {
IssueIconPipe,
],
})
export class TaskDetailPanelComponent implements AfterViewInit, OnDestroy {
export class TaskDetailPanelComponent implements OnInit, AfterViewInit, OnDestroy {
attachmentService = inject(TaskAttachmentService);
taskService = inject(TaskService);
layoutService = inject(LayoutService);
Expand Down Expand Up @@ -403,6 +404,14 @@ export class TaskDetailPanelComponent implements AfterViewInit, OnDestroy {
this.isDragOver = false;
}

@HostListener('window:popstate') onBack(): void {
this.collapseParent();
}

ngOnInit(): void {
window.history.pushState({ taskDetailPanel: true }, '');
}

ngAfterViewInit(): void {
this.taskService.taskDetailPanelTargetPanel$
.pipe(
Expand All @@ -429,6 +438,10 @@ export class TaskDetailPanelComponent implements AfterViewInit, OnDestroy {
}

ngOnDestroy(): void {
if (window.history.state.taskDetailPanel) {
window.history.back();
}

this._onDestroy$.next();
this._onDestroy$.complete();
window.clearTimeout(this._focusTimeout);
Expand Down

0 comments on commit 66790a4

Please sign in to comment.