Skip to content

Fix finding UIScrollViews that are clipped(), masked or combined with clipShape() or cornerRadius() #213

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

Merged
merged 5 commits into from
May 12, 2023

Conversation

paescebu
Copy link
Contributor

@paescebu paescebu commented Apr 5, 2023

This should fix issue:
issues 162

Fixes:

struct ContentView: View {
    var body: some View {
        HStack {
            ScrollViewReader { proxy in
                ScrollView(.horizontal) {
                    TimeLineView()
                }
                .introspectScrollView { scrollView in
                    print(scrollView)    //closure not called when clipped or masked
                }
                .clipped()              // this caused issues
                .mask(Text("Hello"))    // or this
                .clipShape(Rectangle()) // and this
            }
        }
    }
}

@paescebu paescebu changed the title Fix finding UIScrollViews that are clipped, masked or combined with clipShape Fix finding UIScrollViews that are clipped, masked or combined with clipShape Apr 5, 2023
@paescebu paescebu changed the title Fix finding UIScrollViews that are clipped, masked or combined with clipShape Fix finding UIScrollViews that are clipped(), masked or combined with clipShape() Apr 5, 2023
Copy link

@kaweerutk kaweerutk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Collaborator

@davdroman davdroman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks CI in every platform for testNestedScrollView. We can't merge this until that test is fixed.

@paescebu
Copy link
Contributor Author

paescebu commented May 12, 2023

This breaks CI in every platform for testNestedScrollView. We can't merge this until that test is fixed.

You're right. The test is also correct though. It seems that this change breaks the logic as soon as two ScrollViews are in play (either on the same level, or nested).
IMO its not the tests that need to be fixed, it's the implementation itself

@paescebu
Copy link
Contributor Author

paescebu commented May 12, 2023

I think I found a solution, but I feel the name of the new selector is quite verbose. Because first i will search through the hierarchy that was looked through before, and only if it doesn't find the respective ScrollView I apply the selector that goes higher up to its ancestors. Changes pushed

Let me know how this can be improved

@paescebu
Copy link
Contributor Author

I also added a unit test that validates that masked or clipped ScrollViews are also found correctly. (unit tests "correctly" fail if the change is reverted)

@paescebu paescebu requested review from davdroman and kaweerutk May 12, 2023 15:49
@paescebu paescebu changed the title Fix finding UIScrollViews that are clipped(), masked or combined with clipShape() Fix finding UIScrollViews that are clipped(), masked or combined with clipShape() or cornerRadius() May 12, 2023
@davdroman
Copy link
Collaborator

IMO its not the tests that need to be fixed, it's the implementation itself

You're right, I misspoke 😄

Copy link
Collaborator

@davdroman davdroman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great effort, @paescebu 👏

@paescebu
Copy link
Contributor Author

paescebu commented May 12, 2023

thank you @davdroman!
It's my first contribution to another open source library :D Happy to help

@davdroman davdroman merged commit bad095e into siteline:master May 12, 2023
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

Successfully merging this pull request may close these issues.

3 participants