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
This commit is contained in:
llama 2024-12-22 09:29:54 +08:00 committed by GitHub
parent 3a7a1c7346
commit 53a2e34a3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()