From a4b522781cda9e6745c193da17da59f7732b4c73 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Wed, 2 Oct 2024 08:18:21 -0700 Subject: [PATCH] fix: Fix bug that prevented dismissing the widgetdiv in a mutator workspace. (#8600) * fix: Fix bug that prevented dismissing the widgetdiv in a mutator workspace. * fix: Check if the correct workspace is null. * fix: Remove errant this. --- core/widgetdiv.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/widgetdiv.ts b/core/widgetdiv.ts index 9f58bb1c544..b5edc977448 100644 --- a/core/widgetdiv.ts +++ b/core/widgetdiv.ts @@ -166,10 +166,22 @@ export function hideIfOwner(oldOwner: unknown) { * Destroy the widget and hide the div if it is being used by an object in the * specified workspace, or if it is used by an unknown workspace. * - * @param oldOwnerWorkspace The workspace that was using this container. + * @param workspace The workspace that was using this container. */ -export function hideIfOwnerIsInWorkspace(oldOwnerWorkspace: WorkspaceSvg) { - if (ownerWorkspace === null || ownerWorkspace === oldOwnerWorkspace) { +export function hideIfOwnerIsInWorkspace(workspace: WorkspaceSvg) { + let ownerIsInWorkspace = ownerWorkspace === null; + // Check if the given workspace is a parent workspace of the one containing + // our owner. + let currentWorkspace: WorkspaceSvg | null = workspace; + while (!ownerIsInWorkspace && currentWorkspace) { + if (currentWorkspace === workspace) { + ownerIsInWorkspace = true; + break; + } + currentWorkspace = workspace.options.parentWorkspace; + } + + if (ownerIsInWorkspace) { hide(); } }