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

Sometimes swipe gesture doesn't reset (when inside a scroll view / list) #4

Open
aheze opened this issue Apr 15, 2023 · 5 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@aheze
Copy link
Owner

aheze commented Apr 15, 2023

Happens occasionally - the swipe view gets stuck.

View more details...

Stuck between expanded/closed state with unwanted margin on the right

@aheze aheze added the bug Something isn't working label Apr 15, 2023
@heysaik
Copy link

heysaik commented Apr 15, 2023

Facing this with leadingActions specifically

@aheze aheze added the help wanted Extra attention is needed label Apr 19, 2023
@cristianbabin
Copy link

cristianbabin commented Apr 21, 2023

Workaround: just add a .id(UUID()) to SwipeView

I'm using it inside a List and it works

@Juhnkerg
Copy link

Juhnkerg commented Apr 21, 2023

Workaround: just add a .id(UUID()) to SwipeView

I'm using it inside a List and it works

Could you please tell me more about it? I used the following code snippet, but it wouldn't work, swipe gesture doesn't reset.

    SwipeView {
        Container(title: "Basic")
    } trailingActions: { _ in
        SwipeAction("Tap Me!") {}
    }.id(UUID())

@aheze
Copy link
Owner Author

aheze commented Apr 21, 2023

Important information

Just making sure we're on the same page here: to return to the closed state, just do context.state.wrappedValue = .closed. No need to add a custom .id or anything. Example:

SwipeView {
    Text("Swipe to Trigger, Then Return")
        .frame(maxWidth: .infinity)
        .padding(.vertical, 32)
        .background(Color.blue.opacity(0.1))
        .cornerRadius(32)
} trailingActions: { context in
    SwipeAction("Bounce Back") {
        context.state.wrappedValue = .closed /// here!
    }
    .allowSwipeToTrigger()
}
.swipeActionWidth(140)

This works fine.

BounceBack.mov

The actual problem

The problem in this issue is about the swipe view getting stuck midway between the expanded/closed state. I can't consistently reproduce this, but it seems to have something to do with scrolling.

Stuck between expanded/closed state with unwanted margin on the right

@aheze aheze pinned this issue Apr 21, 2023
@Juhnkerg
Copy link

The issue about the swipe view getting stuck midway between the expanded/closed state probably because of the swiftUI Gestures. Using .allowsHitTesting() might help solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants