mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix formatting-only edits not rendering in the timeline
Components of a formatted body were identified by their plain characters, so an edit that only added formatting (e.g. wrapping a word in inline code) kept the same ID. SwiftUI then reused the existing MessageText, whose @State string ignores new input, and the old unformatted text kept rendering. Identify components by the hash of their attributed string so formatting changes produce a new ID.
This commit is contained in:
@@ -257,6 +257,15 @@ struct AttributedStringBuilderTests {
|
||||
#expect(components[1].attributedString.string == "Hidden content")
|
||||
}
|
||||
|
||||
@Test
|
||||
func componentIDChangesWithFormatting() throws {
|
||||
let plain = try #require(attributedStringBuilder.fromHTML("test test test"), "Could not build the attributed string")
|
||||
let formatted = try #require(attributedStringBuilder.fromHTML("test <code>test</code> test"), "Could not build the attributed string")
|
||||
|
||||
#expect(plain.string == formatted.string)
|
||||
#expect(plain.formattedComponents.map(\.id) != formatted.formattedComponents.map(\.id))
|
||||
}
|
||||
|
||||
@Test
|
||||
func detailsWithoutSummary() throws {
|
||||
let htmlString = "<details><p>Content</p></details>"
|
||||
|
||||
Reference in New Issue
Block a user