A small SwiftUI panel displays the summary for an attached document and triggers an action when the button is tapped. The behavior needs to be fixed so that the panel always uses the current model and does not leave stale handlers behind after reconfiguration.
Requirements
- The screen runs on iOS 18 and Swift 6 with strict concurrency checking enabled.
- SwiftUI is used, and all models and views from the example run on
MainActor.
- Input data is passed through
DocumentAttachment and AttachmentSummaryService.
- The summary string format depends on locale, date, and attachment status.
- The
Open button must invoke the action only for the current attachment.
- When the same cell/card is configured again, old closures and old data must not survive the new configuration.
- Deterministic mocks from the example are used for time and network calls.
Reproduction
- Create
DocumentAttachmentPanel with attachment A, locale ru_RU, and a service that returns a string for A.
- Reuse the same view instance with attachment
B without creating a new service.
- Tap
Open.
- Compare the displayed summary and the received callback with the current attachment.
Expected behavior
- After the model is replaced, the summary is recalculated for the new attachment.
- Pressing the button calls the callback for the current attachment, not the previous one.
- Reconfiguration does not preserve old text and old action between configurations.