From 2f3ab66ffeb0517c96a3092d4a04e85359315302 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 May 2021 14:28:24 +0530 Subject: [PATCH] Workaround bug in chrome with jumping to search result in a new html file not working for some books --- src/pyj/read_book/iframe.pyj | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 4df110db3a..a6d00ef1ec 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -750,6 +750,9 @@ class IframeBoss: self.scroll_to_ref(refnum) def show_search_result(self, data, from_load): + if self.load_search_result_timer: + window.clearTimeout(self.load_search_result_timer) + self.load_search_result_timer = None sr = data.search_result if sr.on_discovery: if sr.result_num is 1: @@ -759,7 +762,11 @@ class IframeBoss: self.last_search_at = window.performance.now() x, y = scroll_viewport.x(), scroll_viewport.y() if select_search_result(sr): - self.ensure_selection_visible() + self.ensure_selection_boundary_visible() + if from_load and current_layout_mode() is 'paged': + # workaround bug in chrome where sizes are incorrect in paged + # mode on initial load for some books + self.load_search_result_timer = window.setTimeout(self.ensure_selection_boundary_visible, 750) if self.full_book_search_in_progress and not self.full_book_search_in_progress.first_result_shown and sr.on_discovery: discovered = False if progress_frac() >= self.full_book_search_in_progress.progress_frac_at_start or current_spine_item().index is not self.full_book_search_in_progress.start_spine_index: