Skip to content

Commit 545faa5

Browse files
authored
relayout widget when menubars change (microsoft#183209)
* relayout widget when menubars change fixes microsoft/vscode-internalbacklog#4087 * remove console.log
1 parent fc063a5 commit 545faa5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/vs/platform/actions/browser/toolbar.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IToolBarOptions, ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
88
import { IAction, Separator, SubmenuAction, toAction, WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from 'vs/base/common/actions';
99
import { coalesceInPlace } from 'vs/base/common/arrays';
1010
import { BugIndicatingError } from 'vs/base/common/errors';
11+
import { Emitter, Event } from 'vs/base/common/event';
1112
import { DisposableStore } from 'vs/base/common/lifecycle';
1213
import { localize } from 'vs/nls';
1314
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
@@ -283,6 +284,9 @@ export interface IMenuWorkbenchToolBarOptions extends IWorkbenchToolBarOptions {
283284
*/
284285
export class MenuWorkbenchToolBar extends WorkbenchToolBar {
285286

287+
private readonly _onDidChangeMenuItems = this._store.add(new Emitter<this>());
288+
readonly onDidChangeMenuItems: Event<this> = this._onDidChangeMenuItems.event;
289+
286290
constructor(
287291
container: HTMLElement,
288292
menuId: MenuId,
@@ -309,7 +313,10 @@ export class MenuWorkbenchToolBar extends WorkbenchToolBar {
309313
super.setActions(primary, secondary);
310314
};
311315

312-
this._store.add(menu.onDidChange(updateToolbar));
316+
this._store.add(menu.onDidChange(() => {
317+
updateToolbar();
318+
this._onDidChangeMenuItems.fire(this);
319+
}));
313320
updateToolbar();
314321
}
315322

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export class InteractiveEditorWidget {
290290
}
291291
};
292292
const statusToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.statusToolbar, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, workbenchToolbarOptions);
293+
this._store.add(statusToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
293294
this._store.add(statusToolbar);
294295

295296
// preview editors
@@ -301,6 +302,7 @@ export class InteractiveEditorWidget {
301302
this._elements.message.tabIndex = 0;
302303
this._elements.statusLabel.tabIndex = 0;
303304
const markdownMessageToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.messageActions, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, workbenchToolbarOptions);
305+
this._store.add(markdownMessageToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
304306
this._store.add(markdownMessageToolbar);
305307
}
306308

0 commit comments

Comments
 (0)