OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#59925] ensure correct modal is closed
Tobias Dillmannab3baa90ea7f
diff --git a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts b/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.tsindex 8e6f5574d5c..2c155cff109 100644--- a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts+++ b/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts@@ -30,6 +30,7 @@ import { Injectable, Injector, NgZone } from '@angular/core';import { OpModalService } from 'core-app/shared/components/modal/modal.service';import { HoverCardComponent } from 'core-app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal';import { PortalOutletTarget } from 'core-app/shared/components/modal/portal-outlet-target.enum';+import { Observable } from 'rxjs';@Injectable({ providedIn: 'root' })export class HoverCardTriggerService {@@ -38,6 +39,7 @@ export class HoverCardTriggerService {private mouseInModal = false;private hoverTimeout:number|null = null;private closeTimeout:number|null = null;+ private modal:Observable<HoverCardComponent>|null;// Set to custom when opening the hover card on top of another modalprivate modalTarget:PortalOutletTarget = PortalOutletTarget.Default;private previousTarget:HTMLElement|null = null;@@ -119,7 +121,7 @@ export class HoverCardTriggerService {// There is only one possible slot to insert a modal. If that slot is taken, we assume the other modal// to be more important than a hover card and give up.- const modal = this.opModalService.showIfNotActive(+ this.modal = this.opModalService.showIfNotActive(HoverCardComponent,this.injector,{ turboFrameSrc: turboFrameUrl, event: e },@@ -128,7 +130,7 @@ export class HoverCardTriggerService {this.modalTarget,);- modal?.subscribe((previewModal) => {+ this.modal?.subscribe((previewModal) => {this.modalElement = previewModal.elementRef.nativeElement as HTMLElement;previewModal.alignment = 'top';@@ -158,9 +160,14 @@ export class HoverCardTriggerService {}if (!this.mouseInModal) {- this.opModalService.close();- // Allow opening this target once more, since it has been orderly closed- this.previousTarget = null;+ // The subscription ensures that we only close the current modal if it is indeed a HoverCardComponent.+ // If we just called `opModalService.close()` here, we might close another spot modal instead, such as the+ // share dialog.+ this.modal?.subscribe((_modal) => {+ this.opModalService.close();+ // Allow opening this target once more, since it has been orderly closed+ this.previousTarget = null;+ });}}