From 2c5d58fe4d91c33066757415ada0ef6a41443ae3 Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 10 Feb 2026 17:12:36 +0100 Subject: [PATCH] wait #7985 @3:00 --- js/libs/fluidbook/fluidbook.search.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index dbecec4f..69307361 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -58,7 +58,6 @@ FluidbookSearch.prototype = { }); }, - // The results nav bar provides navigation between results without needing the menu to be open // When it is active, the rest of the interface is hidden initResultsNav: function () { @@ -998,6 +997,7 @@ FluidbookSearch.prototype = { } var $this = this; + let r = new Map(); this.find(q, function (results) { $this.openResults(results); }); @@ -1041,8 +1041,11 @@ FluidbookSearch.prototype = { var spreadEnabled = 0; // Process each spread of pages to collect the ones with results + + var pagesWithHits = []; + this.menuSearchResults.find('.doubleThumb').each(function () { - var currentPages = $(this).data('pages').toString().split(','), totalHits = 0, pagesWithHits = []; + var currentPages = $(this).data('pages').toString().split(','), totalHits = 0; var firstPageWithResult; @@ -1058,7 +1061,6 @@ FluidbookSearch.prototype = { } } - // If there's already a .hits element, this spread has already been processed if ($(this).find('.hits').length > 0) { return; @@ -1093,6 +1095,9 @@ FluidbookSearch.prototype = { } }); + let referencePage = pagesWithHits.find((el) => el >= $this.fluidbook.currentPage) ?? parseInt(pagesWithHits[0]) + console.log(referencePage) + // Set Highlighting of results keywords this.setHighlightTerms(results.terms); this.hideSearchHints(); @@ -1101,8 +1106,8 @@ FluidbookSearch.prototype = { // Redirect to the only result page if the flag is enabled if(this.fluidbook.search.isSearchfloatActive && $this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').length > 0) { setTimeout(function () { - fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').attr('page')); - var pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb').attr('page')); + fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"][data-pages*='+referencePage+']').attr('page')); + var pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb[data-enabled="1"][data-pages*='+referencePage+']').attr('page')); $this.openResultsNav(pageNumber); fluidbook.nav.burger.close(); }, 100); -- 2.39.5