@@ -70,9 +70,6 @@ export class SearchController {
7070 this . notifyMatchUpdate ( ) ;
7171 this . showMatch ( this . matches [ 0 ] ) ;
7272 } else {
73- if ( this . onNoResults ) {
74- this . onNoResults ( ) ;
75- }
7673 if ( this . onUpdateCounter ) {
7774 this . onUpdateCounter ( 0 , 0 ) ;
7875 }
@@ -96,7 +93,6 @@ export class SearchController {
9693 }
9794 }
9895
99- this . notifyMatchUpdate ( ) ;
10096 this . showMatch ( this . matches [ this . currentMatchIndex ] ) ;
10197 }
10298
@@ -117,13 +113,19 @@ export class SearchController {
117113 }
118114
119115 showMatch ( match ) {
120- if ( match . pageNum === this . activePage && this . activeTextLayer ) {
121- // Already on the same page, just redraw highlights to try to avoid full re-render
122- // Update: calling getPageCallback might be ignored by index.js if page is same,
123- // so we MUST redraw manually here to update the 'selected' highlight.
124- this . drawPageMatches ( match . pageNum , this . activeTextLayer ) ;
116+ const textLayer = this . activeTextLayer || document . getElementById ( "text" ) ;
117+
118+ let currentPage = this . activePage ;
119+ if ( typeof channel !== 'undefined' && channel . getPage ( ) ) {
120+ currentPage = channel . getPage ( ) ;
125121 }
126- // Always request page navigation to ensure we are on the right page
122+
123+ if ( match . pageNum === currentPage && textLayer ) {
124+ this . drawPageMatches ( match . pageNum , textLayer ) ;
125+ } else if ( this . activePage === 0 && textLayer ) {
126+ this . drawPageMatches ( match . pageNum , textLayer ) ;
127+ }
128+
127129 this . getPageCallback ( match . pageNum ) ;
128130 }
129131
0 commit comments