-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Description
I've hit a weird issue with the UI not updating. I am using a NavigationSplitView
and the right and middle column share the same scoped store/state. A form/sheet is presented from the right column and on save the state in the parent reducer is properly updated. The UI in the right column is updated but the left is not.
I reproduced the issue in a smaller sample app (use iPad) and have slowly been removing parts of it to help isolate the issue. I believe I've got it down to the smallest possible. In the sample I have removed the NavigationSplitView
and just placed the two views embedded within a parent to simplify it a bit.
Here is a video of the sample app. You can see on save the right view's "Sum" has been updated but the left column's has not. If you force an update via a local @State
property the UI is correct. Also any other actions will trigger it to update as well.
ViewNotUpdating.mov
Some observations:
- Updating the number from the form save action actually works depending on how you update the state.
// Doesn't work ❌
state.numbers[id: form.id] = form
// Works weirdly enough ✅
state.numbers[id: form.id]?.number = form.number
Also if you add another property to the parent state other than the @Presents form
and the numbers
list and update it on the save it works.
- The form/sheet is required to make it happen. If you do a increment action without the form it all works correctly.
- If you strip things down further and copy the bodies of the
SumView
andNumberListView
into theSplitView
it works correctly.
Admittedly I'm not sure if this is a bug in TCA or SwiftUI or I am doing something wrong since I am a bit rusty with TCA but everything seems correct as far as I can tell.
Checklist
- I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- If possible, I've reproduced the issue using the
main
branch of this package. - This issue hasn't been addressed in an existing GitHub issue or discussion.
Expected behavior
Both views should update
Actual behavior
Only the right column updates on the form saveFormTapped
action.
Steps to reproduce
Run the sample app.
- Tap one of the numbers on the right
- Increment it
- Tap Save
- See right column is update and left is not
- Tap "Force Update" and see it now is correct
The Composable Architecture version information
1.11.2
Destination operating system
iOS 17
Xcode version information
15.4
Swift Compiler version information
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: x86_64-apple-macosx14.0