diff --git a/src/vs/base/browser/ui/dropdown/dropdown.ts b/src/vs/base/browser/ui/dropdown/dropdown.ts index 22693e1971c142b096c2c4dd907df00ac147f996..196179901120d367ae07d017a6cd37c063ac8e5d 100644 --- a/src/vs/base/browser/ui/dropdown/dropdown.ts +++ b/src/vs/base/browser/ui/dropdown/dropdown.ts @@ -214,6 +214,7 @@ export interface IDropdownMenuOptions extends IBaseDropdownOptions { actions?: ReadonlyArray; actionProvider?: IActionProvider; menuClassName?: string; + menuAsChild?: boolean; // scope down for #99448 } export class DropdownMenu extends BaseDropdown { @@ -222,6 +223,7 @@ export class DropdownMenu extends BaseDropdown { private _actions: ReadonlyArray = []; private actionProvider?: IActionProvider; private menuClassName: string; + private menuAsChild?: boolean; constructor(container: HTMLElement, options: IDropdownMenuOptions) { super(container, options); @@ -230,6 +232,7 @@ export class DropdownMenu extends BaseDropdown { this.actions = options.actions || []; this.actionProvider = options.actionProvider; this.menuClassName = options.menuClassName || ''; + this.menuAsChild = !!options.menuAsChild; } set menuOptions(options: IMenuOptions | undefined) { @@ -267,7 +270,7 @@ export class DropdownMenu extends BaseDropdown { onHide: () => this.onHide(), actionRunner: this.menuOptions ? this.menuOptions.actionRunner : undefined, anchorAlignment: this.menuOptions ? this.menuOptions.anchorAlignment : AnchorAlignment.LEFT, - anchorAsContainer: true + anchorAsContainer: this.menuAsChild }); } @@ -289,10 +292,11 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem { private keybindings?: (action: IAction) => ResolvedKeybinding | undefined; private clazz: string | undefined; private anchorAlignmentProvider: (() => AnchorAlignment) | undefined; + private menuAsChild?: boolean; - constructor(action: IAction, menuActions: ReadonlyArray, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment); - constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment); - constructor(action: IAction, menuActionsOrProvider: ReadonlyArray | IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) { + constructor(action: IAction, menuActions: ReadonlyArray, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment, menuAsChild?: boolean); + constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment, menuAsChild?: boolean); + constructor(action: IAction, menuActionsOrProvider: ReadonlyArray | IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment, menuAsChild?: boolean) { super(null, action); this.menuActionsOrProvider = menuActionsOrProvider; @@ -302,6 +306,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem { this.keybindings = keybindings; this.clazz = clazz; this.anchorAlignmentProvider = anchorAlignmentProvider; + this.menuAsChild = menuAsChild; } render(container: HTMLElement): void { @@ -322,7 +327,8 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem { const options: IDropdownMenuOptions = { contextMenuProvider: this.contextMenuProvider, - labelRenderer: labelRenderer + labelRenderer: labelRenderer, + menuAsChild: this.menuAsChild }; // Render the DropdownMenu around a simple action to toggle it diff --git a/src/vs/base/browser/ui/toolbar/toolbar.ts b/src/vs/base/browser/ui/toolbar/toolbar.ts index 2ce6e5599dc5f6a8c7673b5abc1d48f6ff76bb0d..9badee8eb9639a469305f72feb394acf2fe37796 100644 --- a/src/vs/base/browser/ui/toolbar/toolbar.ts +++ b/src/vs/base/browser/ui/toolbar/toolbar.ts @@ -69,7 +69,8 @@ export class ToolBar extends Disposable { this.actionRunner, this.options.getKeyBinding, toolBarMoreIcon.classNames, - this.options.anchorAlignmentProvider + this.options.anchorAlignmentProvider, + true ); this.toggleMenuActionViewItem.value.setActionContext(this.actionBar.context);