@@ -122,7 +122,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
122
122
read_only,
123
123
} = props ;
124
124
125
- const cell_list_node = useRef < HTMLElement | null > ( null ) ;
125
+ const cellListDivRef = useRef < any > ( null ) ;
126
126
const is_mounted = useIsMountedRef ( ) ;
127
127
const frameActions = useNotebookFrameActions ( ) ;
128
128
@@ -140,7 +140,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
140
140
frame_actions . focus ( true ) ;
141
141
// setup a click handler so we can manage focus
142
142
$ ( window ) . on ( "click" , window_click ) ;
143
- frame_actions . cell_list_div = $ ( cell_list_node . current ) ;
143
+ frame_actions . cell_list_div = $ ( cellListDivRef . current ) ;
144
144
145
145
return ( ) => {
146
146
saveScroll ( ) ;
@@ -172,7 +172,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
172
172
} , [ cur_id , scroll , scroll_seq ] ) ;
173
173
174
174
const handleCellListRef = useCallback ( ( node : any ) => {
175
- cell_list_node . current = node ;
175
+ cellListDivRef . current = node ;
176
176
frameActions . current ?. set_cell_list_div ( node ) ;
177
177
} , [ ] ) ;
178
178
@@ -186,8 +186,8 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
186
186
// We don't actually need to do anything though since our virtuoso
187
187
// integration automatically solves this same problem.
188
188
} else {
189
- if ( cell_list_node . current != null ) {
190
- frameActions . current ?. set_scrollTop ( cell_list_node . current . scrollTop ) ;
189
+ if ( cellListDivRef . current != null ) {
190
+ frameActions . current ?. set_scrollTop ( cellListDivRef . current . scrollTop ) ;
191
191
}
192
192
}
193
193
} , [ use_windowed_list ] ) ;
@@ -206,7 +206,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
206
206
let scrollHeight : number = 0 ;
207
207
for ( const tm of [ 0 , 1 , 100 , 250 , 500 , 1000 ] ) {
208
208
if ( ! is_mounted . current ) return ;
209
- const elt = cell_list_node . current ;
209
+ const elt = cellListDivRef . current ;
210
210
if ( elt != null && elt . scrollHeight !== scrollHeight ) {
211
211
// dynamically rendering actually changed something
212
212
elt . scrollTop = scrollTop ;
@@ -218,7 +218,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
218
218
219
219
function window_click ( event : any ) : void {
220
220
// if click in the cell list, focus the cell list; otherwise, blur it.
221
- const elt = $ ( cell_list_node . current ) ;
221
+ const elt = $ ( cellListDivRef . current ) ;
222
222
// list no longer exists, nothing left to do
223
223
// Maybe elt can be null? https://github.com/sagemathinc/cocalc/issues/3580
224
224
if ( elt . length == 0 ) return ;
@@ -242,8 +242,8 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
242
242
}
243
243
}
244
244
245
- async function scroll_cell_list_not_windowed ( scroll : Scroll ) : Promise < void > {
246
- const node = $ ( cell_list_node . current ) ;
245
+ async function scrollCellListNotWindowed ( scroll : Scroll ) : Promise < void > {
246
+ const node = $ ( cellListDivRef . current ) ;
247
247
if ( node . length == 0 ) return ;
248
248
if ( typeof scroll === "number" ) {
249
249
node . scrollTop ( node . scrollTop ( ) + scroll ) ;
@@ -307,7 +307,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
307
307
align = "end" ;
308
308
isNotVisible = true ;
309
309
} else {
310
- const scroller = $ ( cell_list_node . current ) ;
310
+ const scroller = $ ( cellListDivRef . current ) ;
311
311
const cell = scroller . find ( `#${ cur_id } ` ) ;
312
312
if ( scroller [ 0 ] == null ) return ;
313
313
if ( cell [ 0 ] == null ) return ;
@@ -384,7 +384,7 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
384
384
scrollCellListVirtuoso ( scroll ) ;
385
385
} else {
386
386
// scroll not using windowed list
387
- scroll_cell_list_not_windowed ( scroll ) ;
387
+ scrollCellListNotWindowed ( scroll ) ;
388
388
}
389
389
}
390
390
@@ -562,7 +562,6 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
562
562
563
563
let body ;
564
564
565
- const cellListDivRef = useRef < HTMLDivElement > ( null ) ;
566
565
const virtuosoHeightsRef = useRef < { [ index : number ] : number } > ( { } ) ;
567
566
568
567
const cellListResize = useResizeObserver ( { ref : cellListDivRef } ) ;
0 commit comments