@@ -84,6 +84,7 @@ export class BetweenCellToolbar extends CellOverlayPart {
84
84
notebookEditor : this . _notebookEditor ,
85
85
$mid : MarshalledId . NotebookCellActionContext
86
86
} ;
87
+ this . updateInternalLayoutNow ( element ) ;
87
88
}
88
89
89
90
override updateInternalLayoutNow ( element : ICellViewModel ) {
@@ -163,7 +164,7 @@ export class CellTitleToolbarPart extends CellOverlayPart {
163
164
return this . _model ;
164
165
}
165
166
166
- private _initialize ( model : CellTitleToolbarModel ) : CellTitleToolbarView {
167
+ private _initialize ( model : CellTitleToolbarModel , element : ICellViewModel ) : CellTitleToolbarView {
167
168
if ( this . _view ) {
168
169
return this . _view ;
169
170
}
@@ -180,8 +181,8 @@ export class CellTitleToolbarPart extends CellOverlayPart {
180
181
deleteToolbar . setActions ( model . deleteActions . primary , model . deleteActions . secondary ) ;
181
182
}
182
183
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 ) ;
185
186
186
187
this . _view = {
187
188
toolbar,
@@ -197,7 +198,7 @@ export class CellTitleToolbarPart extends CellOverlayPart {
197
198
198
199
override didRenderCell ( element : ICellViewModel ) : void {
199
200
const model = this . _initializeModel ( ) ;
200
- const view = this . _initialize ( model ) ;
201
+ const view = this . _initialize ( model , element ) ;
201
202
this . cellDisposables . add ( registerStickyScroll ( this . _notebookEditor , element , this . toolbarContainer , { extraOffset : 4 , min : - 14 } ) ) ;
202
203
203
204
this . updateContext ( view , < INotebookCellActionContext > {
@@ -213,19 +214,21 @@ export class CellTitleToolbarPart extends CellOverlayPart {
213
214
view . deleteToolbar . context = toolbarContext ;
214
215
}
215
216
216
- private setupChangeListeners ( toolbar : ToolBar , menu : IMenu ) : void {
217
+ private setupChangeListeners ( toolbar : ToolBar , menu : IMenu , initActions : { primary : IAction [ ] ; secondary : IAction [ ] } ) : void {
217
218
// #103926
218
219
let dropdownIsVisible = false ;
219
220
let deferredUpdate : ( ( ) => void ) | undefined ;
220
221
221
- this . updateActions ( toolbar , menu ) ;
222
+ this . updateActions ( toolbar , initActions ) ;
222
223
this . _register ( menu . onDidChange ( ( ) => {
223
224
if ( dropdownIsVisible ) {
224
- deferredUpdate = ( ) => this . updateActions ( toolbar , menu ) ;
225
+ const actions = getCellToolbarActions ( menu ) ;
226
+ deferredUpdate = ( ) => this . updateActions ( toolbar , actions ) ;
225
227
return ;
226
228
}
227
229
228
- this . updateActions ( toolbar , menu ) ;
230
+ const actions = getCellToolbarActions ( menu ) ;
231
+ this . updateActions ( toolbar , actions ) ;
229
232
} ) ) ;
230
233
this . _rootClassDelegate . toggle ( 'cell-toolbar-dropdown-active' , false ) ;
231
234
this . _register ( toolbar . onDidChangeDropdownVisibility ( visible => {
@@ -242,10 +245,7 @@ export class CellTitleToolbarPart extends CellOverlayPart {
242
245
} ) ) ;
243
246
}
244
247
245
- private updateActions ( toolbar : ToolBar , menu : IMenu ) {
246
-
247
- const actions = getCellToolbarActions ( menu ) ;
248
-
248
+ private updateActions ( toolbar : ToolBar , actions : { primary : IAction [ ] ; secondary : IAction [ ] } ) {
249
249
const hadFocus = DOM . isAncestor ( document . activeElement , toolbar . getElement ( ) ) ;
250
250
toolbar . setActions ( actions . primary , actions . secondary ) ;
251
251
if ( hadFocus ) {
0 commit comments