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

[#59879] amiably animate hover cards

Tobias Dillmannd4abe0ae614a
diff --git a/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.sass b/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.sass
index dcab4bc4fa7..44e0bd0a973 100644
--- a/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.sass
+++ b/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.sass
@@ -12,11 +12,8 @@
background-color: var(--body-background)
z-index: 5000
width: 500px
+ min-height: 95px
box-shadow: var(--shadow-floating-medium)
pointer-events: all
padding: var(--overlay-paddingBlock-normal)
border-radius: var(--overlay-borderRadius)
-
- &.user-sized
- width: 500px
- height: 182px
diff --git a/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts b/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts
index eb5b92e6381..619d9a7cbfa 100644
--- a/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts
+++ b/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts
@@ -58,17 +58,18 @@ export class HoverCardComponent extends OpModalComponent implements OnInit {
@ViewChild('turboFrame')
set turboFrame(frame:ElementRef<HTMLIFrameElement>|undefined) {
if (frame !== undefined) {
- if (this.turboFrameSrc.includes('/users/')) {
- // User hover cards require additional space, this must be designated before loading the turbo frame so that
- // the rough size of the hover card can be adjusted in advance. This makes the popup appear smoothly.
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
- this.elementRef.nativeElement.querySelector('.op-hover-card')?.classList.add('user-sized');
- }
+ // When a new turbo frame is set, hide the modal until the frame is loaded.
+ // Since the size of the new content is unknown in advance, showing a loading indicator within the hover card
+ // leads to a bumpy result once the actual content is inserted and the card extends its dimensions.
+ this.setOpacity(this.elementRef, 0);
frame.nativeElement?.addEventListener('turbo:frame-load', () => {
const modal = this.elementRef.nativeElement as HTMLElement;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any
void this.reposition(modal, this.locals.event.target as HTMLElement);
+
+ // Content has been loaded, card has been positioned. Show it!
+ this.setOpacity(this.elementRef, 1);
});
}
}
@@ -114,4 +115,10 @@ export class HoverCardComponent extends OpModalComponent implements OnInit {
top: `${y}px`,
});
}
+
+ private setOpacity(elementRef:ElementRef, opacity:number) {
+ const element = elementRef.nativeElement as HTMLElement;
+
+ element.style.opacity = opacity.toString();
+ }
}