Skip to content

Commit

Permalink
fix: Fix bug that prevented dismissing the widgetdiv in a mutator wor…
Browse files Browse the repository at this point in the history
…kspace. (#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.
  • Loading branch information
gonfunko authored Oct 2, 2024
1 parent ec5b6e7 commit a4b5227
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions core/widgetdiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down

0 comments on commit a4b5227

Please sign in to comment.