File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,11 @@ export class SideMenuView<
187
187
this . onKeyDown as EventListener ,
188
188
true
189
189
) ;
190
+
191
+ // Setting capture=true ensures that any parent container of the editor that
192
+ // gets scrolled will trigger the scroll event. Scroll events do not bubble
193
+ // and so won't propagate to the document by default.
194
+ pmView . root . addEventListener ( "scroll" , this . onScroll , true ) ;
190
195
}
191
196
192
197
updateState = ( state : SideMenuState < BSchema , I , S > ) => {
@@ -473,6 +478,13 @@ export class SideMenuView<
473
478
return evt ;
474
479
}
475
480
481
+ onScroll = ( ) => {
482
+ if ( this . state ?. show ) {
483
+ this . state . referencePos = this . hoveredBlock ! . getBoundingClientRect ( ) ;
484
+ this . emitUpdate ( this . state ) ;
485
+ }
486
+ } ;
487
+
476
488
// Needed in cases where the editor state updates without the mouse cursor
477
489
// moving, as some state updates can require a side menu update. For example,
478
490
// adding a button to the side menu which removes the block can cause the
@@ -515,6 +527,7 @@ export class SideMenuView<
515
527
this . onKeyDown as EventListener ,
516
528
true
517
529
) ;
530
+ this . pmView . root . removeEventListener ( "scroll" , this . onScroll , true ) ;
518
531
}
519
532
}
520
533
You can’t perform that action at this time.
0 commit comments