-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Fix ScrollView
interactions with Android's CoordinatorLayout
#44099
base: main
Are you sure you want to change the base?
Fix ScrollView
interactions with Android's CoordinatorLayout
#44099
Conversation
ScrollView
interactions with Android CoordinatorLayout
ScrollView
interactions with Android CoordinatorLayout
ScrollView
interactions with Android CoordinatorLayout
ScrollView
interactions with Android's CoordinatorLayout
I also experimented with integrating CoordinatorLayout in RN screens previously and this was a needed change to make it work. |
I got the If you set |
Thanks for the PR! I'd be inclined to not switch to The other suggestions made here make sense, and would be happy look at a PR that fixes the issue of missing event when scroll view content is less than the scroll view height. |
I would love some testing guidance (maybe issues with behaviour I should put particular emphasis to test?) & more precise description of what do I need to provide you with to change this inclination (if thats feasible). Right now I haven't noticed any unusual behaviour after applying suggested changes (beside fixed interactions with CoordinatorLayout) Here's potentially useful diff of As for attempts to patch the implementation w/o inheriting from |
I think argument for |
@alanleedev @javache currently, the render(): React.Node | React.Element<string> {
const [NativeDirectionalScrollView, NativeDirectionalScrollContentView] =
this.props.horizontal === true
? NativeHorizontalScrollViewTuple
: NativeVerticalScrollViewTuple; So you have ScrollView for vertical scroll and HorizontalScrollView for horizontal. In Android docs, it says this for vertical scroll: And also:
So I think this PR is completely justified. Another alternative could be: this.props.nestedScrollEnabled === true ? NativeNestedVerticalScrollView
this.props.horizontal === true
? NativeHorizontalScrollViewTuple
: NativeVerticalScrollViewTuple; But is it worth to write another implementation ( |
Couldn't scroll in a bottomsheet or sheet because the coordinator was intercepting it. This interception is a workaround for [a (react native or android?) bug](facebook/react-native#44099) where the nested scroll stops working of scroll content shorter than height. Checked if the event target is a sheet and don't intercept in that case.
I refreshed my memory on this one. The Android @kkafar could you check whether If the |
Hey folks, thanks for the suggestions. The proposals do seem to make sense but as a framework we need to be bit more careful about the changes and the impact. I'm trying to have more internal discussion on this and will try to give an update next week. |
@alanleedev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@grahammendick @kkafar If we can fix the case for |
@alanleedev Yep, that would work |
I'll be able to devote my time to do that (try to patch current scrollview) somewhere early next week, if that's ok I volunteer. |
@kkafar That would be great. Thanks. |
@kkafar Any updates on this? |
## Description This PR introduces series of features & changes: 1. possibility of specifying custom detents for form sheets on devices with iOS 16 or newer, 2. changes existing form sheet API of `Screen` component (namely types of values accepted), 3. Android form sheets (bottom sheets presented in current presentation context (in iOS terms) with dimming view with configurable interaction. The form sheet supports up to three detent levels with additional option of `fitToContents` 4. Android Footer component that works together with `formSheet` presentation style 5. 🚧 Android modal bottom sheet - similar to `formSheet`, however the sheet is mounted under separate window. 6. 🚧 iOS Footer component - similar to Android 7. Usage of Material 3 8. series of new props allowing for: a. controlling style of the `Screen` component (necessary workaround for issue with flickering on iOS, b. controlling whether the screen fragment of particular screen should be unmounted or not on Android when the screen is on JS stack but not visible (necessary to achieve "staying form sheet" when navigating back to a screen with presented form sheet), c. listening for `sheetDetentChange` events, in case of Android stable & dragging states are reported, in case of iOS only stable states d. todo: describe rest ## Changes ## Known issues 1. [x] ~After recent commits - iOS compilation on Fabric~ 2. [ ] Android: issue with nested scrollview - invalid behaviour when there is not enough content for scrollview to scroll (viewport is >= content size). Solvable by patching react-native: facebook/react-native#44099, no other workaround found. There is one approach [suggested by grahammendick](https://github.com/grahammendick/navigation/blob/916688d267bd3fc520e2e22328b6aa66124f52ed/NavigationReactNative/src/android/src/main/java/com/navigation/reactnative/CoordinatorLayoutView.java#L96-L148), however yet untested. 3. [ ] Android 'modal' presentation can crash randomly (unknown reason yet, can be deffered) ## Test code and steps to reproduce I've used & extended `Test1649` to present all capabilities of new API. ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: <!-- For adding new props to native-stack --> - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes
comment from @kkafar on linked PR:
|
Hey, sorry (!) for a such long delay. PTO + always something higher in backlog. I do have still this on my radar, as I need to fix this behaviour to land with stable |
@kkafar Thanks for the update. |
## Description This PR introduces series of features & changes: 1. possibility of specifying custom detents for form sheets on devices with iOS 16 or newer, 2. changes existing form sheet API of `Screen` component (namely types of values accepted), 3. Android form sheets (bottom sheets presented in current presentation context (in iOS terms) with dimming view with configurable interaction. The form sheet supports up to three detent levels with additional option of `fitToContents` 4. Android Footer component that works together with `formSheet` presentation style 5. 🚧 Android modal bottom sheet - similar to `formSheet`, however the sheet is mounted under separate window. 6. 🚧 iOS Footer component - similar to Android 7. Usage of Material 3 8. series of new props allowing for: a. controlling style of the `Screen` component (necessary workaround for issue with flickering on iOS, b. controlling whether the screen fragment of particular screen should be unmounted or not on Android when the screen is on JS stack but not visible (necessary to achieve "staying form sheet" when navigating back to a screen with presented form sheet), c. listening for `sheetDetentChange` events, in case of Android stable & dragging states are reported, in case of iOS only stable states d. todo: describe rest ## Changes ## Known issues 1. [x] ~After recent commits - iOS compilation on Fabric~ 2. [ ] Android: issue with nested scrollview - invalid behaviour when there is not enough content for scrollview to scroll (viewport is >= content size). Solvable by patching react-native: facebook/react-native#44099, no other workaround found. There is one approach [suggested by grahammendick](https://github.com/grahammendick/navigation/blob/916688d267bd3fc520e2e22328b6aa66124f52ed/NavigationReactNative/src/android/src/main/java/com/navigation/reactnative/CoordinatorLayoutView.java#L96-L148), however yet untested. 3. [ ] Android 'modal' presentation can crash randomly (unknown reason yet, can be deffered) ## Test code and steps to reproduce I've used & extended `Test1649` to present all capabilities of new API. ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: <!-- For adding new props to native-stack --> - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes
Here's some more evidence supporting migrating to |
Summary:
Hello, I'm recently researching & implementing native material 3 bottom sheets, toolbars etc. and hitting the wall with various interactions with react-native's
ScrollView
. Here's one example that's documented on SO: link, but there at least few others related to gestures & dragging (undraggable bottom sheet whenscrollViewContentLength < scrollViewHeight
, happy to elaborate here). This comes down to the fact, that standardandroid.widget.ScrollView
does not work well withCoordinatorLayout
. Therefore I'm coming forward with question whether you would consider inheriting afterandroidx.core.widget.NestedScrollView
which solves aforementioned issues (and mostlikely many others related to interaction withCoordinatorLayout
). I want to point out that even Android docs & source code suggest to useNestedScrollView
for vertical scrolling in lieu ofScrollView
.Happy to iterate here, would love some guidance especially in testing. I'm also open for implementing
NestedScrollingChild
/NestedScrollingParent
/ ... interfaces if you don't think change in inheritance chain is possible.Changelog:
[ANDROID] [FIXED] -
ReactScrollView
interactions withCoordinatorLayout
Test Plan: