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

make hover cards more stable

Tobias Dillmannaffd7214abc2
diff --git a/frontend/src/stimulus/controllers/hover-card-trigger.controller.ts b/frontend/src/stimulus/controllers/hover-card-trigger.controller.ts
index 8cea1823c52..99c2d03a1fe 100644
--- a/frontend/src/stimulus/controllers/hover-card-trigger.controller.ts
+++ b/frontend/src/stimulus/controllers/hover-card-trigger.controller.ts
@@ -41,6 +41,8 @@ import { computePosition, flip, limitShift, shift } from '@floating-ui/dom';
export default class HoverCardTriggerController extends ApplicationController {
static targets = ['trigger', 'card'];
+ private readonly triggerTargets:HTMLElement[];
+
private mouseInModal = false;
private hoverTimeout:number|null = null;
private closeTimeout:number|null = null;
@@ -113,9 +115,19 @@ export default class HoverCardTriggerController extends ApplicationController {
e.stopPropagation();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- const el = e.target as HTMLElement;
+ let el = e.target as HTMLElement;
if (!el) { return; }
+ // If the trigger contains other elements, one of them might have triggered the event. We want to only refer to
+ // the original trigger as this makes event and state handling easier. Find the correct target element:
+ if (!this.triggerTargets.some((trigger) => trigger === el)) {
+ // If the element is not a trigger itself, one of its parents must be. Find the correct one.
+ const trigger = el.closest('[data-hover-card-trigger-target="trigger"]') as HTMLElement;
+ if (!trigger) { return; }
+
+ el = trigger;
+ }
+
if (this.previousTarget && this.previousTarget === el) {
// Re-entering the trigger counts as hovering over the card:
this.mouseInModal = true;