From 853555a9fc9f4ddbbf8f39f90b66e4151c42ddd3 Mon Sep 17 00:00:00 2001 From: david-swift Date: Thu, 4 Jan 2024 15:16:44 +0100 Subject: [PATCH] Make the entry row a bit safer --- Sources/Adwaita/View/Forms/EntryRow.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/Adwaita/View/Forms/EntryRow.swift b/Sources/Adwaita/View/Forms/EntryRow.swift index f76ab92..1b1968a 100644 --- a/Sources/Adwaita/View/Forms/EntryRow.swift +++ b/Sources/Adwaita/View/Forms/EntryRow.swift @@ -28,6 +28,9 @@ public struct EntryRow: Widget { /// The identifier for the suffix content. let suffixID = "suffix" + /// The identifier for the title. + let titleID = "title" + /// Initialize an entry row. /// - Parameters: /// - title: The row's title. @@ -72,7 +75,9 @@ public struct EntryRow: Widget { _ = row.addSuffix(suffixContent.view) } _ = row.changeHandler { - text = row.contents() + if row.contents() != text { + text = row.contents() + } } update(row: row) return .init(row, content: [prefixID: [prefixContent], suffixID: [suffixContent]]) @@ -81,7 +86,10 @@ public struct EntryRow: Widget { /// Update the entry row. /// - Parameter row: The entry row. func update(row: Libadwaita.EntryRow) { - _ = row.title(title) + if row.fields[titleID] as? String != title { + _ = row.title(title) + row.fields[titleID] = title + } if row.contents() != text { row.setContents(text) }