Skip to content

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

[#55581] do not try to show a modal twice at the same time

Tobias Dillmann2ad5f34045eb
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.ts
index 41e4deac609..1ef3bb63b4c 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
@@ -89,15 +89,20 @@ export class HoverCardTriggerService {
this.hoverTimeout = window.setTimeout(() => {
this.parseHoverCardOptions(el);
- this.opModalService.show(
+ // 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(
HoverCardComponent,
this.injector,
{ turboFrameSrc: cleanedTurboFrameUrl, event: e },
true,
false,
this.modalTarget,
- ).subscribe((previewModal) => {
+ );
+
+ modal?.subscribe((previewModal) => {
this.modalElement = previewModal.elementRef.nativeElement as HTMLElement;
+ previewModal.alignment = 'top';
void previewModal.reposition(this.modalElement, el);
});
diff --git a/frontend/src/app/shared/components/modal/modal.service.ts b/frontend/src/app/shared/components/modal/modal.service.ts
index c495e3d8a3d..eacdd7b1ad3 100644
--- a/frontend/src/app/shared/components/modal/modal.service.ts
+++ b/frontend/src/app/shared/components/modal/modal.service.ts
@@ -67,6 +67,26 @@ export class OpModalService {
});
}
+ /**
+ * Checks whether there is currently an active modal. Only shows the requested modal if this is not the case.
+ * Will return null if showing the modal is denied.
+ * @see show
+ */
+ public showIfNotActive<T extends OpModalComponent>(
+ modal:ComponentType<T>,
+ injector:Injector|'global',
+ locals:Record<string, unknown> = {},
+ notFullscreen = false,
+ mobileTopPosition = false,
+ target = PortalOutletTarget.Default,
+ ):Observable<T>|null {
+ if (this.activeModalInstance$.value) {
+ return null;
+ }
+
+ return this.show(modal, injector, locals, notFullscreen, mobileTopPosition, target);
+ }
+
/**
* Open a Modal reference and append it to the portal
*