In the button, remove the part where you're directly setting the contextMenu boolean.
Button {
selectedMessage = message
} label: {
MessageItem(message: message)
}
.buttonStyle(.plain)
Then, add an onChange trigger in the same rank as your fullScreenCover.
.onChange(of: selectedMessage) { newValue in
contextMenu = newValue != nil
}
That way, it will always trigger after, rather than relying on the lines being synchronous.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: