Skip to content

Commit a52c0dc

Browse files
committed
do not expand menu from modal
1 parent 5222389 commit a52c0dc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/menu/menu-tree-structure-workspace-context-base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { UmbArrayState, UmbObjectState } from '@umbraco-cms/backoffice/observabl
99
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1010
import { UmbAncestorsEntityContext, UmbParentEntityContext, type UmbEntityModel } from '@umbraco-cms/backoffice/entity';
1111
import { linkEntityExpansionEntries } from '@umbraco-cms/backoffice/utils';
12+
import { UMB_MODAL_CONTEXT } from '@umbraco-cms/backoffice/modal';
1213

1314
interface UmbMenuTreeStructureWorkspaceContextBaseArgs {
1415
treeRepositoryAlias: string;
@@ -33,13 +34,18 @@ export abstract class UmbMenuTreeStructureWorkspaceContextBase extends UmbContex
3334
#parentContext = new UmbParentEntityContext(this);
3435
#ancestorContext = new UmbAncestorsEntityContext(this);
3536
#sectionSidebarMenuContext?: typeof UMB_SECTION_SIDEBAR_MENU_SECTION_CONTEXT.TYPE;
37+
#isModalContext: boolean = false;
3638

3739
constructor(host: UmbControllerHost, args: UmbMenuTreeStructureWorkspaceContextBaseArgs) {
3840
super(host, UMB_MENU_STRUCTURE_WORKSPACE_CONTEXT);
3941
// 'UmbMenuStructureWorkspaceContext' is Obsolete, will be removed in v.18
4042
this.provideContext('UmbMenuStructureWorkspaceContext', this);
4143
this.#args = args;
4244

45+
this.consumeContext(UMB_MODAL_CONTEXT, (modalContext) => {
46+
this.#isModalContext = modalContext !== undefined;
47+
});
48+
4349
this.consumeContext(UMB_SECTION_SIDEBAR_MENU_SECTION_CONTEXT, (instance) => {
4450
this.#sectionSidebarMenuContext = instance;
4551
});
@@ -109,7 +115,7 @@ export abstract class UmbMenuTreeStructureWorkspaceContextBase extends UmbContex
109115
this.#setAncestorData(data);
110116

111117
const menuItemAlias = this.manifest?.meta?.menuItemAlias;
112-
if (menuItemAlias) {
118+
if (menuItemAlias && !this.#isModalContext) {
113119
this.#expandSectionSidebarMenu(structureItems, menuItemAlias);
114120
}
115121
}

src/Umbraco.Web.UI.Client/src/packages/core/menu/menu-variant-tree-structure-workspace-context-base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
99
import { UmbAncestorsEntityContext, UmbParentEntityContext, type UmbEntityModel } from '@umbraco-cms/backoffice/entity';
1010
import { UMB_SUBMITTABLE_TREE_ENTITY_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
1111
import { linkEntityExpansionEntries } from '@umbraco-cms/backoffice/utils';
12+
import { UMB_MODAL_CONTEXT, type UmbModalContext } from '@umbraco-cms/backoffice/modal';
1213

1314
interface UmbMenuVariantTreeStructureWorkspaceContextBaseArgs {
1415
treeRepositoryAlias: string;
@@ -33,6 +34,7 @@ export abstract class UmbMenuVariantTreeStructureWorkspaceContextBase extends Um
3334
#parentContext = new UmbParentEntityContext(this);
3435
#ancestorContext = new UmbAncestorsEntityContext(this);
3536
#sectionSidebarMenuContext?: typeof UMB_SECTION_SIDEBAR_MENU_SECTION_CONTEXT.TYPE;
37+
#isModalContext: boolean = false;
3638

3739
public readonly IS_MENU_VARIANT_STRUCTURE_WORKSPACE_CONTEXT = true;
3840

@@ -42,6 +44,10 @@ export abstract class UmbMenuVariantTreeStructureWorkspaceContextBase extends Um
4244
this.provideContext('UmbMenuStructureWorkspaceContext', this);
4345
this.#args = args;
4446

47+
this.consumeContext(UMB_MODAL_CONTEXT, (modalContext) => {
48+
this.#isModalContext = modalContext !== undefined;
49+
});
50+
4551
this.consumeContext(UMB_SECTION_SIDEBAR_MENU_SECTION_CONTEXT, (instance) => {
4652
this.#sectionSidebarMenuContext = instance;
4753
});
@@ -118,7 +124,7 @@ export abstract class UmbMenuVariantTreeStructureWorkspaceContextBase extends Um
118124
this.#setAncestorData(data);
119125

120126
const menuItemAlias = this.manifest?.meta?.menuItemAlias;
121-
if (menuItemAlias) {
127+
if (menuItemAlias && !this.#isModalContext) {
122128
this.#expandSectionSidebarMenu(structureItems, menuItemAlias);
123129
}
124130
}

0 commit comments

Comments
 (0)