Skip to content

Commit 1b46fd3

Browse files
Pass widget consistently to toolbar enablement handlers (#16826)
1 parent aa006f4 commit 1b46fd3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export class TabBarToolbar extends ReactWidget {
178178
anchor,
179179
context: this.current?.node || this.node,
180180
contextKeyService: this.contextKeyService,
181+
includeAnchorArg: false,
181182
onHide: () => toDisposeOnHide.dispose()
182183
});
183184
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ class AbstractToolbarItemImpl<T extends TabBarToolbarActionBase> {
7373
return actionVisible && contextMatches;
7474
}
7575

76-
isEnabled(widget?: Widget): boolean {
76+
isEnabled(widget: Widget): boolean {
7777
return this.action.command ? this.commandRegistry.isEnabled(this.action.command, widget) : !!this.action.menuPath;
7878
}
79-
isToggled(): boolean {
80-
return this.action.command ? this.commandRegistry.isToggled(this.action.command) : true;
79+
isToggled(widget: Widget): boolean {
80+
return this.action.command ? this.commandRegistry.isToggled(this.action.command, widget) : false;
8181
}
8282
}
8383

@@ -121,22 +121,22 @@ export class RenderedToolbarItemImpl extends AbstractToolbarItemImpl<RenderedToo
121121
}
122122
}
123123

124-
render(widget?: Widget | undefined): React.ReactNode {
124+
render(widget: Widget): React.ReactNode {
125125
return this.renderItem(widget);
126126
}
127127

128-
protected getToolbarItemClassNames(widget?: Widget): string[] {
128+
protected getToolbarItemClassNames(widget: Widget): string[] {
129129
const classNames = [TabBarToolbar.Styles.TAB_BAR_TOOLBAR_ITEM];
130130
if (this.isEnabled(widget)) {
131131
classNames.push('enabled');
132132
}
133-
if (this.isToggled()) {
133+
if (this.isToggled(widget)) {
134134
classNames.push('toggled');
135135
}
136136
return classNames;
137137
}
138138

139-
protected resolveKeybindingForCommand(widget: Widget | undefined, command: string | undefined): string {
139+
protected resolveKeybindingForCommand(widget: Widget, command: string | undefined): string {
140140
let result = '';
141141
if (this.action.command) {
142142
const bindings = this.keybindingRegistry.getKeybindingsForCommand(this.action.command);
@@ -190,7 +190,7 @@ export class RenderedToolbarItemImpl extends AbstractToolbarItemImpl<RenderedToo
190190
e.currentTarget.classList.remove('active');
191191
};
192192

193-
protected executeCommand(e: React.MouseEvent<HTMLElement>, widget?: Widget): void {
193+
protected executeCommand(e: React.MouseEvent<HTMLElement>, widget: Widget): void {
194194
e.preventDefault();
195195
e.stopPropagation();
196196

@@ -203,7 +203,7 @@ export class RenderedToolbarItemImpl extends AbstractToolbarItemImpl<RenderedToo
203203
}
204204
};
205205

206-
protected renderItem(widget?: Widget): React.ReactNode {
206+
protected renderItem(widget: Widget): React.ReactNode {
207207
let innerText = '';
208208
const classNames = [];
209209
const command = this.action.command ? this.commandRegistry.getCommand(this.action.command) : undefined;

0 commit comments

Comments
 (0)