Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task modifier not found if placed after custom modifiers #342

Open
qeude opened this issue Oct 16, 2024 · 0 comments
Open

Task modifier not found if placed after custom modifiers #342

qeude opened this issue Oct 16, 2024 · 0 comments

Comments

@qeude
Copy link

qeude commented Oct 16, 2024

Hi!

I recently tried ViewInspector in one of my app, and faced a weird problem in which the order had an incident on discoverability of tasks modifier.

var body: some View {
  VStack(spacing: 0) {
    ContainerView(viewModel: viewModel, errorProcessor: { DefaultErrorViewModel(error: $0) })
  }
  .navigationBarTitleDisplayMode(.inline)
  .flashMessage(isPresented: $viewModel.isFlashMessageVisible, model: viewModel.flashMessage)
  .anotherCustomModifier()
  .task(id: viewModel.taskId) {
    await viewModel.refreshData()
  }
  .task(id: isFocused) {
    guard isFocused == true else { return }
  }
}

Here with that code, doing something like try await sut.inspect().find(ViewType.VStack.self).callTask(id: UUID()) doesn't find any task modifier while with the following code it does

var body: some View {
  VStack(spacing: 0) {
    ContainerView(viewModel: viewModel, errorProcessor: { DefaultErrorViewModel(error: $0) })
  }
  .task(id: viewModel.taskId) {
    await viewModel.refreshData()
  }
  .task(id: isFocused) {
    guard isFocused == true else { return }
  }
  .navigationBarTitleDisplayMode(.inline)
  .flashMessage(isPresented: $viewModel.isFlashMessageVisible, model: viewModel.flashMessage)
  .anotherCustomModifier()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant