pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.35k stars 1.44k forks source link

Tree-based navigation: dismiss action is not sent when navigating back on macOS #2182

Closed vadymmarkov closed 1 year ago

vadymmarkov commented 1 year ago

Description

I've recently updated TCA from a04be28aff42678566b76eb502ae4644bc4b36c2 to the latest commit b2815caa1727d72180836b85578272b763cc4853 from prerelease/1.0 branch and discovered that tree-based navigation stopped working as expected on macOS.

Update: Can also be reproduced using the main branch of the package.

For example, suppose we have the "featureA" screen wrapped in NavigationStack, and "featureB" is presented in a drill-down from "featureA" using navigationDestination(store:state: action:destination:). When going back from "featureB" to "featureA" using the default "back" button the .dismiss action is not being sent to set the child state back to nil.

Strangely, this happens on macOS only, but works as expected on iOS. I don't know if it's a SwiftUI bug, but I didn't experience this behaviour with TCA from a04be28aff42678566b76eb502ae4644bc4b36c2.

Checklist

Expected behavior

The PresentationAction/dismiss action should be sent to nil out the child state when going back to the parent feature using the navigation bar "back" button.

Actual behavior

The PresentationAction/dismiss action is not being sent to nil out the child state when going back to the parent feature using the navigation bar "back" button.

Steps to reproduce

You can reproduce the incorrect behaviour in the attached project. Changing package commit to a04be28aff42678566b76eb502ae4644bc4b36c2 fixes the issue.

NavigationTestCase.zip

The Composable Architecture version information

b2815caa1727d72180836b85578272b763cc4853

Destination operating system

macOS 13

Xcode version information

14.3.1

Swift Compiler version information

swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
vadymmarkov commented 1 year ago

Can also reproduce it using the main branch of the package, so it's not prerelease only issue.

Jeankio commented 1 year ago

This also seems to be happening on iOS when targeting to SDK 16.0

stephencelis commented 1 year ago

Thanks for the report! I've been able to bisect and find that the problem was introduced in this commit: https://github.com/pointfreeco/swift-composable-architecture/commit/fa6e44a8c472c6de08773a617221c00709163341

Will look into fixing soon!

stephencelis commented 1 year ago

@Jeankio Do you have an iOS 16 repro? I'm able to repro on macOS but not iOS.