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

ViewModifier, causes bounds overflow #541

Open
shial4 opened this issue Aug 12, 2023 · 0 comments
Open

ViewModifier, causes bounds overflow #541

shial4 opened this issue Aug 12, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@shial4
Copy link

shial4 commented Aug 12, 2023

Describe the bug
Adding ViewModifier to view causes bounds overflow crash, in any browser.
You need to have enough examples for it to happen. (2x didn't trigger) but below code, does the trick for me

HStack {
                Rectangle()
                    .fill(Color.purple)
                    .frame(width: 100, height: 100)
                    .onTapGesture() {
                        print("🟢 1st gesture")
                    }
                    .onTapGesture() {
                        print("🟢 2nd gesture, should not be called")
                    }
                    .onTapGesture() {
                        print("🟢 3rd gesture, should not be called")
                    }
                    .simultaneousGesture(
                        TapGesture().onEnded({ _ in
                            print("🟢 simultaneousGesture gesture")
                        })
                    )
                    .onLongPressGesture {
                        print("🟢 onLongPressGesture")
                    }
                Text("Tap Parent")
            }
            .background(
                Color.gray
                    .onTapGesture() {
                        print("🩶 Background gesture")
                    }
            )
            .onTapGesture() {
                print("🔵 Parent gesture")
            }

Used code to trigger the issue

private struct GesturePreferenceModifier<G: Gesture>: ViewModifier {
    let gesture: G

    func body(content: Content) -> some View {
        GestureView( gesture: gesture, content: content )
    }
}

with the modifier applied like this:

modifier(GesturePreferenceModifier(gesture: gesture.body))

To Reproduce
Steps to reproduce the behavior:

  1. Create a preference key
  2. Create HStack View with modifier applied to it and its subviews
  3. change state (i.e. on tap)
  4. See error

Expected behavior
App works as expected

Screenshots

Desktop (please complete the following information):

@shial4 shial4 added the bug Something isn't working label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants