Skip to content

Commit 3065b49

Browse files
committed
Overlay part needs layout update in didRenderCell
1 parent f9fb40f commit 3065b49

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export class BetweenCellToolbar extends CellOverlayPart {
8484
notebookEditor: this._notebookEditor,
8585
$mid: MarshalledId.NotebookCellActionContext
8686
};
87+
this.updateInternalLayoutNow(element);
8788
}
8889

8990
override updateInternalLayoutNow(element: ICellViewModel) {
@@ -163,7 +164,7 @@ export class CellTitleToolbarPart extends CellOverlayPart {
163164
return this._model;
164165
}
165166

166-
private _initialize(model: CellTitleToolbarModel): CellTitleToolbarView {
167+
private _initialize(model: CellTitleToolbarModel, element: ICellViewModel): CellTitleToolbarView {
167168
if (this._view) {
168169
return this._view;
169170
}
@@ -180,8 +181,8 @@ export class CellTitleToolbarPart extends CellOverlayPart {
180181
deleteToolbar.setActions(model.deleteActions.primary, model.deleteActions.secondary);
181182
}
182183

183-
this.setupChangeListeners(toolbar, model.titleMenu);
184-
this.setupChangeListeners(deleteToolbar, model.deleteMenu);
184+
this.setupChangeListeners(toolbar, model.titleMenu, model.actions);
185+
this.setupChangeListeners(deleteToolbar, model.deleteMenu, model.deleteActions);
185186

186187
this._view = {
187188
toolbar,
@@ -197,7 +198,7 @@ export class CellTitleToolbarPart extends CellOverlayPart {
197198

198199
override didRenderCell(element: ICellViewModel): void {
199200
const model = this._initializeModel();
200-
const view = this._initialize(model);
201+
const view = this._initialize(model, element);
201202
this.cellDisposables.add(registerStickyScroll(this._notebookEditor, element, this.toolbarContainer, { extraOffset: 4, min: -14 }));
202203

203204
this.updateContext(view, <INotebookCellActionContext>{
@@ -213,19 +214,21 @@ export class CellTitleToolbarPart extends CellOverlayPart {
213214
view.deleteToolbar.context = toolbarContext;
214215
}
215216

216-
private setupChangeListeners(toolbar: ToolBar, menu: IMenu): void {
217+
private setupChangeListeners(toolbar: ToolBar, menu: IMenu, initActions: { primary: IAction[]; secondary: IAction[] }): void {
217218
// #103926
218219
let dropdownIsVisible = false;
219220
let deferredUpdate: (() => void) | undefined;
220221

221-
this.updateActions(toolbar, menu);
222+
this.updateActions(toolbar, initActions);
222223
this._register(menu.onDidChange(() => {
223224
if (dropdownIsVisible) {
224-
deferredUpdate = () => this.updateActions(toolbar, menu);
225+
const actions = getCellToolbarActions(menu);
226+
deferredUpdate = () => this.updateActions(toolbar, actions);
225227
return;
226228
}
227229

228-
this.updateActions(toolbar, menu);
230+
const actions = getCellToolbarActions(menu);
231+
this.updateActions(toolbar, actions);
229232
}));
230233
this._rootClassDelegate.toggle('cell-toolbar-dropdown-active', false);
231234
this._register(toolbar.onDidChangeDropdownVisibility(visible => {
@@ -242,10 +245,7 @@ export class CellTitleToolbarPart extends CellOverlayPart {
242245
}));
243246
}
244247

245-
private updateActions(toolbar: ToolBar, menu: IMenu) {
246-
247-
const actions = getCellToolbarActions(menu);
248-
248+
private updateActions(toolbar: ToolBar, actions: { primary: IAction[]; secondary: IAction[] }) {
249249
const hadFocus = DOM.isAncestor(document.activeElement, toolbar.getElement());
250250
toolbar.setActions(actions.primary, actions.secondary);
251251
if (hadFocus) {

0 commit comments

Comments
 (0)