Skip to content

Commit c9f9101

Browse files
Pass widget around toolbar handlers more consistently
1 parent cbce08d commit c9f9101

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/core/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ abstract class AbstractToolbarMenuWrapper {
4242
protected abstract icon: string | undefined;
4343
protected abstract tooltip: string | undefined;
4444
protected abstract text: string | undefined;
45-
protected abstract executeCommand(e: React.MouseEvent<HTMLDivElement, MouseEvent>): void;
45+
protected abstract executeCommand(widget: Widget, e: React.MouseEvent<HTMLDivElement, MouseEvent>): void;
4646

47-
isEnabled(): boolean {
47+
isEnabled(widget: Widget): boolean {
4848
if (CommandMenu.is(this.menuNode)) {
49-
return this.menuNode.isEnabled();
49+
return this.menuNode.isEnabled(widget);
5050
}
5151
return true;
5252
}
53-
isToggled(): boolean {
53+
isToggled(widget: Widget): boolean {
5454
if (CommandMenu.is(this.menuNode) && this.menuNode.isToggled) {
55-
return !!this.menuNode.isToggled();
55+
return !!this.menuNode.isToggled(widget);
5656
}
5757
return false;
5858
}
@@ -101,7 +101,7 @@ abstract class AbstractToolbarMenuWrapper {
101101
return <div key={this.id} className={TabBarToolbar.Styles.TAB_BAR_TOOLBAR_ITEM + ' enabled menu'}>
102102
<div className={codicon(icon, true)}
103103
title={this.text}
104-
onClick={e => this.executeCommand(e)}
104+
onClick={e => this.executeCommand(widget, e)}
105105
/>
106106
<div className={ACTION_ITEM} onClick={event => this.showPopupMenu(widget, this.menuPath!, event, contextMatcher)} >
107107
<div className={codicon('chevron-down') + ' chevron'} />
@@ -111,7 +111,7 @@ abstract class AbstractToolbarMenuWrapper {
111111
return <div key={this.id} className={TabBarToolbar.Styles.TAB_BAR_TOOLBAR_ITEM + ' enabled menu'}>
112112
<div className={codicon(icon, true)}
113113
title={this.text}
114-
onClick={e => this.executeCommand(e)}
114+
onClick={e => this.executeCommand(widget, e)}
115115
/>
116116
</div>;
117117
}
@@ -130,9 +130,9 @@ export class ToolbarMenuNodeWrapper extends AbstractToolbarMenuWrapper implement
130130
super(commandRegistry, menuRegistry, contextKeyService, contextMenuRenderer);
131131
}
132132

133-
executeCommand(e: React.MouseEvent<HTMLDivElement, MouseEvent>): void {
133+
executeCommand(widget: Widget, e: React.MouseEvent<HTMLDivElement, MouseEvent>): void {
134134
if (CommandMenu.is(this.menuNode)) {
135-
this.menuNode.run();
135+
this.menuNode.run(widget);
136136
}
137137
}
138138

@@ -173,7 +173,7 @@ export class ToolbarSubmenuWrapper extends AbstractToolbarMenuWrapper implements
173173
return this.toolbarItem.command ? this.commandRegistry.isEnabled(this.toolbarItem.command, widget) : !!this.toolbarItem.menuPath;
174174
}
175175

176-
protected executeCommand(e: React.MouseEvent<HTMLElement>, widget?: Widget): void {
176+
protected executeCommand(widget: Widget, e: React.MouseEvent<HTMLElement>): void {
177177
e.preventDefault();
178178
e.stopPropagation();
179179

packages/core/src/browser/shell/tab-bar-toolbar/tab-toolbar-item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import { ActionMenuNode, GroupImpl, MenuNode } from '../../../common/menu';
2828
export interface TabBarToolbarItem {
2929
id: string;
3030
isVisible(widget: Widget): boolean;
31-
isEnabled(widget?: Widget): boolean;
32-
isToggled(): boolean;
31+
isEnabled(widget: Widget): boolean;
32+
isToggled(widget: Widget): boolean;
3333
render(widget?: Widget): React.ReactNode;
3434
onDidChange?: Event<void>;
3535
group?: string;

0 commit comments

Comments
 (0)