@@ -97,6 +97,35 @@ describe(['tagdesktop'], 'Scroll through document, modify heading', function() {
9797 desktopHelper . assertScrollbarPosition ( 'vertical' , 325 , 360 ) ;
9898 } ) ;
9999
100+ it ( 'Jump to image when cursor not visible' , function ( ) {
101+ // Regression test: when the text cursor is hidden, double-clicking
102+ // an image in the navigator must still scroll the viewport to it.
103+ // assertVisiblePage alone is not sufficient as #StatePageNumber
104+ // reflects the selection's page (which core updates regardless of
105+ // whether the viewport scrolls), so check the actual scrollbar.
106+ expandSection ( 'Images' ) ;
107+
108+ cy . cGet ( '#navigator-dock-wrapper' ) . scrollTo ( 0 , 0 , { ensureScrollable : false } ) ;
109+
110+ // Jump to a heading so a cursor exists at a known position.
111+ cy . cGet ( '#contenttree' ) . contains ( '.jsdialog.sidebar.ui-treeview-cell-text' , 'Feedback' ) . dblclick ( ) ;
112+ desktopHelper . assertVisiblePage ( 2 , 2 , 8 ) ;
113+ desktopHelper . assertScrollbarPosition ( 'vertical' , 45 , 75 ) ;
114+
115+ // Scroll document to the top so the text cursor is no longer visible.
116+ desktopHelper . scrollWriterDocumentToTop ( ) ;
117+ desktopHelper . updateFollowingUsers ( ) ;
118+ desktopHelper . assertScrollbarPosition ( 'vertical' , 0 , 10 ) ;
119+
120+ // Double-click an image on a different page (graphics10 is on page 5).
121+ // Without the fix, _onUpdateCursor returns early because the text
122+ // cursor is invisible, so the viewport never scrolls and the
123+ // scrollbar stays near 0.
124+ cy . cGet ( '#contenttree' ) . contains ( '.jsdialog.sidebar.ui-treeview-cell-text' , 'graphics10' ) . dblclick ( ) ;
125+ desktopHelper . assertVisiblePage ( 5 , 5 , 8 ) ;
126+ desktopHelper . assertScrollbarPosition ( 'vertical' , 100 , 400 ) ;
127+ } ) ;
128+
100129 it . skip ( 'Jump to element. Document -> Navigator' , function ( ) {
101130 // Move the cursor into elements in Document, and check
102131 // if navigator contentTree scroll to the element and select that,
0 commit comments