From 38c8d66b5b0b5df429c1de51acfba661129157f8 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sat, 31 Aug 2024 10:51:25 +0300 Subject: [PATCH] readerhighlight: fix showing anchored popup dialog --- frontend/apps/reader/modules/readerhighlight.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index c714b3457..9ee993143 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -1286,9 +1286,12 @@ function ReaderHighlight:_getHighlightMenuAnchor() elseif position == "bottom" then anchor_y = self.screen_h - Size.padding.small else -- "gesture" - local text_box = self.ui.document:getWordFromPosition(self.gest_pos).sbox - if self.ui.paging then - text_box = self.view:pageToScreenTransform(self.ui.paging.current_page, text_box) + local text_box = self.ui.document:getWordFromPosition(self.gest_pos) + if text_box then + text_box = text_box.sbox + if text_box and self.ui.paging then + text_box = self.view:pageToScreenTransform(self.ui.paging.current_page, text_box) + end end if text_box == nil then return end -- fallback to "center" anchor_y = text_box.y + text_box.h + Size.padding.small -- do not stick to the box