From 7fdc3b72483888fd16092b02af354b46cae6092b Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Tue, 28 Nov 2023 08:03:28 +0100 Subject: [PATCH] fix(session-viewer): Disable pointer event while resizing sessions This commit fixes a small bug that was introduced in #1150. When the pointer events are not disabled on the iframe, some pointer events are "stolen" by the iframe. Therefore, they can not be used by our event handlers. This led to a "jumpy" behaviour while resizing. --- .../floating-window-manager.component.ts | 6 ++---- .../session-iframe.component.html | 11 +++++++---- .../session/session-viewer.service.ts | 19 +++++++++++++++++++ .../tiling-window-manager.component.html | 2 +- .../tiling-window-manager.component.ts | 3 +++ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts b/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts index debd6543e..d3e0cb55a 100644 --- a/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts +++ b/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts @@ -14,8 +14,6 @@ import { SessionViewerService, ViewerSession } from '../session-viewer.service'; }) @UntilDestroy() export class FloatingWindowManagerComponent implements OnInit { - draggingActive = false; - constructor(public sessionViewerService: SessionViewerService) {} ngOnInit(): void { @@ -25,11 +23,11 @@ export class FloatingWindowManagerComponent implements OnInit { } dragStart(): void { - this.draggingActive = true; + this.sessionViewerService.disableAllSessions(); } dragStop(): void { - this.draggingActive = false; + this.sessionViewerService.enableAllSessions(); } trackBySessionId(_: number, session: ViewerSession): string { diff --git a/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html b/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html index c304f291f..5e1a7283c 100644 --- a/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html +++ b/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html @@ -10,16 +10,19 @@ > diff --git a/frontend/src/app/sessions/session/session-viewer.service.ts b/frontend/src/app/sessions/session/session-viewer.service.ts index 8adc3df87..ba9566e98 100644 --- a/frontend/src/app/sessions/session/session-viewer.service.ts +++ b/frontend/src/app/sessions/session/session-viewer.service.ts @@ -74,6 +74,24 @@ export class SessionViewerService { this._sessions.next(updatedSessions); } + disableAllSessions(): void { + this._sessions.next( + this._sessions.value?.map((curSession) => ({ + ...curSession, + disabled: true, + })), + ); + } + + enableAllSessions(): void { + this._sessions.next( + this._sessions.value?.map((curSession) => ({ + ...curSession, + disabled: false, + })), + ); + } + resizeSessions(): void { document.querySelectorAll('iframe').forEach((iframe) => { const session = this._sessions.value?.find( @@ -137,4 +155,5 @@ export type ViewerSession = Session & { focused: boolean; reloadToResize: boolean; fullscreen: boolean; + disabled: boolean; }; diff --git a/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.html b/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.html index d516f4918..9731a877b 100644 --- a/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.html +++ b/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.html @@ -71,7 +71,7 @@
diff --git a/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.ts b/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.ts index a061060b8..16bbc48df 100644 --- a/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.ts +++ b/frontend/src/app/sessions/session/tiling-window-manager/tiling-window-manager.component.ts @@ -59,6 +59,7 @@ export class TilingWindowManagerComponent implements OnInit { } onMouseDown(event: MouseEvent, index: number): void { + this.sessionViewerService.disableAllSessions(); const leftSession = this.getSessionByIndex(index); const rightSession = this.getSessionByIndex(index + 1); @@ -91,6 +92,8 @@ export class TilingWindowManagerComponent implements OnInit { @HostListener('window:mouseup') onMouseUp(): void { if (this.isValidResizeState(this.resizeState)) { + // Only trigger if resize is active + this.sessionViewerService.enableAllSessions(); this.resizeState = {}; this.sessionViewerService.resizeSessions(); }