From 8127ae4bbadbe6ad7b7cbfab11f614c6ad8b103c Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 7 Sep 2026 16:28:06 +0100 Subject: [PATCH] Fix text body lingering under image preview PreviewPane set bodyText from onResultChanged, reading derived/entry that are themselves bindings on result. Depending on evaluation order the handler saw the previous entry, leaving a stale text body visible under the image column. Derive bodyText declaratively and gate the text body on the textual types. --- PreviewPane.qml | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/PreviewPane.qml b/PreviewPane.qml index 08ff775..5e4cdc2 100644 --- a/PreviewPane.qml +++ b/PreviewPane.qml @@ -21,22 +21,19 @@ Item { readonly property color chipBg: Util.alpha(fg, 0.07) readonly property color lineColor: Util.alpha(fg, 0.16) - property string bodyText: "" - - onResultChanged: prepare() - - function prepare() { - bodyText = "" - if (!entry) return - var t = derived - if (t === "json") { - var pretty = Classify.prettyJson(String(entry.text || ""), 200000) - bodyText = pretty || String(entry.text || "") - } else if (t === "html") { - bodyText = Classify.stripHtml(String(entry.text || "")) || String(entry.text || "") - } else if (t === "text" || t === "code" || t === "email" || t === "number") { - bodyText = String(entry.text || "") - } + // Textual types render in the scrollable body; every other type has its + // own block below. Derived as bindings (not set from onResultChanged) so + // the body text and the type can never disagree mid-update, which used to + // leave a stale text body visible underneath an image preview. + readonly property bool textual: derived === "text" || derived === "code" + || derived === "email" || derived === "number" + || derived === "json" || derived === "html" + readonly property string bodyText: { + if (!entry || !textual) return "" + var raw = String(entry.text || "") + if (derived === "json") return Classify.prettyJson(raw, 200000) || raw + if (derived === "html") return Classify.stripHtml(raw) || raw + return raw } function rawSafe() { @@ -197,7 +194,7 @@ Item { anchors.right: parent.right anchors.topMargin: Style.space(10) anchors.bottomMargin: Style.space(10) - visible: root.bodyText !== "" + visible: root.textual && root.bodyText !== "" clip: true contentWidth: width contentHeight: bodyEdit.implicitHeight