From 53a2e34a3f5cd13aa1ef3cb4c4ba580abec3b1d3 Mon Sep 17 00:00:00 2001 From: llama <100429699+iamllama@users.noreply.github.com> Date: Sun, 22 Dec 2024 09:29:54 +0800 Subject: [PATCH] Fix missing buttons on bottom bar when window is narrow (#3653) * Delay offsetHeight query to account for reflow * Handle invalid value if webview page was deleted --- qt/aqt/toolbar.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qt/aqt/toolbar.py b/qt/aqt/toolbar.py index 2ae8e6d72..56fcb206e 100644 --- a/qt/aqt/toolbar.py +++ b/qt/aqt/toolbar.py @@ -246,8 +246,18 @@ class BottomWebView(ToolbarWebView): self.hidden = False if self.mw.state == "review": - self.evalWithCallback( - "document.documentElement.offsetHeight", self.animate_height + # delay to account for reflow + def cb(height: int | None): + # "When QWebEnginePage is deleted, the callback is triggered with an invalid value" + if height is not None: + self.animate_height(height) + + self.mw.progress.single_shot( + 50, + lambda: self.evalWithCallback( + "document.documentElement.offsetHeight", cb + ), + False, ) else: self.adjustHeightToFit()