Giter Club home page Giter Club logo

Comments (11)

cdedagit avatar cdedagit commented on June 11, 2024

Issue persists on
swift-composable-architecture.git @ 1.5.0
swiftui-navigation.git @ 1.2.0

from swift-composable-architecture.

mbrandonw avatar mbrandonw commented on June 11, 2024

Hi @kdeda, can you please describe exactly what the problem is, and the steps to reproduce the problem. It is not clear right now.

Also, the project you have provided is quite complex. I would recommend trying to minimize it a great deal to make it easier for someone to help. Ideally it should be a project only involving legacyAlert since that is what you are reporting a problem with.

from swift-composable-architecture.

kdeda avatar kdeda commented on June 11, 2024

Say you have a main FeatureA with a ViewA that has 2 child features (FeatureB and FeatureC)
FeatureA can trigger and handle its own .legacyAlert

Each child feature, FeatureB and FeatureC has its own view, ViewB and ViewC
Each child feature can trigger and handle their own .legacyAlert

When these 2 child features are integrated into the main FeatureA/ViewA
the management of .legacyAlert is interrupted.

The attached Xcode project should demonstrate the issue.

from swift-composable-architecture.

cdedagit avatar cdedagit commented on June 11, 2024

Also, the project you have provided is quite complex. I would recommend trying to minimize it a great deal to make it easier for someone to help. Ideally it should be a project only involving legacyAlert since that is what you are reporting a problem with.

I tried to make it as short as possible.
One Parent Feature with 2 Child Features using Switch and CaseLet to switch between features.

from swift-composable-architecture.

kdeda avatar kdeda commented on June 11, 2024

The top "Alert Me" Action goes to the FeatureA
The "Switch to Other" changes the current child view/feaure displayed
The bottom "Alert Me" Action goes to the FeatureB or FeatureC

Screenshot 2023-11-30 at 2 36 37 PM

from swift-composable-architecture.

stephencelis avatar stephencelis commented on June 11, 2024

@kdeda I'm pretty certain is a vanilla SwiftUI problem with the original iOS 13 alert view modifier, which our library simply calls under the hood. One of the reasons why we have an "I have determined whether this bug is also reproducible in a vanilla SwiftUI project" checkbox for issues is that a lot of these bugs are not TCA-specific, and it's good to confirm that vanilla behavior works first.

If I recall, the general workaround is to throw alerts into parts of the view hierarchy where they are better behaved, e.g. inside a background modifier, though you may want to search for vanilla solutions to the problem.

I'm going to close this for now, but if you do determine that the issue is reproducible only in TCA, please file a new issue that demonstrates it working in vanilla SwiftUI.

from swift-composable-architecture.

kdeda avatar kdeda commented on June 11, 2024

Thank you,
I forgot about the entire vanilla thing, since I rarely use it.

from swift-composable-architecture.

kdeda avatar kdeda commented on June 11, 2024

Also your previous code worked which lead me to believe these where related ...

from swift-composable-architecture.

kdeda avatar kdeda commented on June 11, 2024

Bingo moving around the location .legacyAlert is attached makes a difference.
So we have a workaround.

from swift-composable-architecture.

mbrandonw avatar mbrandonw commented on June 11, 2024

This is just a vanilla SwiftUI bug and is not related to TCA at all. Here is a simple reproduction of the problem in plain SwiftUI:

import SwiftUI

struct AppView: View {
  @State var isAlertPresented = false

  var body: some View {
    VStack {
      Button {
        isAlertPresented = true
      } label: {
        Text("Alert Me")
      }
      Child1()
        .border(.yellow)
    }
    .alert(isPresented: self.$isAlertPresented) {
      Alert(title: Text("Hello"))
    }
  }
}

struct Child1: View {
  @State var isAlertPresented = false

  var body: some View {
    VStack {

      HStack {
        Button {
          self.isAlertPresented = true
        } label: {
          Text("Alert Me")
        }
      }
    }
    .alert(isPresented: self.$isAlertPresented) {
      Alert(title: Text("Hello"))
    }
  }
}

The first alert button works but the second does not. But if you comment out the alert(isPresented:) in the AppView body then the second alert button will work, but of course the first will not.

It seems there is a SwiftUI bug on Mac that prevents multiple alert modifiers from working.

Since this is not an issue with our library I am going to convert it to a discussion.

from swift-composable-architecture.

mbrandonw avatar mbrandonw commented on June 11, 2024

Oh sorry, I didn't see @stephencelis's response!

from swift-composable-architecture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.