[frameworks/kirigami] src/forms/flat: FormGroup/flat: Consider also invisible items for implicitWidth

Marco Martin <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 64edc234c7755ff90f89b0fd30d80b2e4337b407 by Marco Martin.
Committed on 06/08/2026 at 08:37.
Pushed by mart into branch 'master'.

FormGroup/flat: Consider also invisible items for implicitWidth

sometimes form entries appear and disappear dynamically.

We don't want the whole layout to move or relayout itself too mcih when
some entries appear, so always consider the maximum implicit width
it would have if every entry was always visible all the time

M  +5    -1    src/forms/flat/FormGroup.qml

https://invent.kde.org/frameworks/kirigami/-/commit/64edc234c7755ff90f89b0fd30d80b2e4337b407

diff --git a/src/forms/flat/FormGroup.qml b/src/forms/flat/FormGroup.qml
index 030dd04ea..c1a0263ca 100644
--- a/src/forms/flat/FormGroup.qml
+++ b/src/forms/flat/FormGroup.qml
@@ -58,7 +58,7 @@ FT.FormGroup {
             text: root.title
         }
         contentItem: Item {
-            implicitWidth: innerLayout.implicitWidth + __assignedWidthForLabels//+ innerLayout.labelWidth
+            implicitWidth: innerLayout.implicitWidthWithInvisible + __assignedWidthForLabels
             implicitHeight: innerLayout.implicitHeight
             ColumnLayout {
                 id: innerLayout
@@ -67,10 +67,14 @@ FT.FormGroup {
                     leftMargin: root.parent.parent.__collapsed ? 0 : root.__assignedWidthForLabels
                 }
                 property real labelWidth: 0
+                // Consider also invisible items when
+                property real implicitWidthWithInvisible: 0
                 onImplicitWidthChanged: {
                     let w = 0;
+                    implicitWidthWithInvisible = 0
                     for (let entry of children) {
                         w = Math.max(w, entry?.__textLabelWidth ?? 0);
+                        implicitWidthWithInvisible = Math.max(implicitWidthWithInvisible, entry.implicitWidth, entry.Layout.preferredWidth)
                     }
                     labelWidth = w;
                 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.