-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
nestedScrollEnabled prop not working in ScrollView (Android) with horizontal direction #21436
Comments
Can you run If you believe this information is irrelevant to the reported issue, you may write |
I am closing this issue because it does not contain the necessary environment info, and there has been no followup in a while. If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here. |
Anyone? I believe it's a bug. |
I have the same problem. This has been tested both on Expo and a standalone React Native app, both in appetize emulator and on a Xiaomi Pocophone F1. Same behavior, no horizontal nested scrolling on Android, but works great on iOS Code here https://snack.expo.io/@esbenvb/scrollview-tests Android behavior https://vimeo.com/322265966 iOS behavior https://vimeo.com/322266040
|
Confirm, I have the same issue with nested horizontal scrolling. |
Have the same issue |
Same issue here |
+1 any fix regarding this? |
Having the same issue. nestedScrollEnabled property works fine for vertical/vertical or vertical/horizontal (and vice versa) but seems to have no effect for nested horizontal scrollviews inside of another horizontal scrollview. |
I'm experiencing the same issue. @smm76 yep, tried this hackish workaround too, but it doesn't feel 'fluid' enough. Please reopen the issue. |
@zhongwuzw , can you please re-open this issue or please tell any other collaborator to re-open it, since the @react-native-bot closed it. |
For the brave hearts who fight with this issue, here's my workaround. I have a horizontal On my inner import throttle from 'lodash/throttle';
...
<ScrollView
horizontal={true}
scrollEventThrottle={16}
// ... bla bla
onTouchStart={() => {
if (Platform.OS === 'android') {
this.props.onTouchStartDisableScrollOnAndroid(); // disables parent scroll
// If the `onScrollEndDrag` event is not fired almost immediately
// after this one (and user doesn't start dragging)
// fire up `onTouchEndEnableScrollOnAndroid` and enable back
// the parent horizontal view scroll.
// This may happen when the user quickly taps on the component
// but doesn't start dragging.
this.throttledOnScrollEndDragOnAndroid = throttle(
this.props.onTouchEndEnableScrollOnAndroid, // enables parent scroll
300,
{
leading: false,
},
);
this.throttledOnScrollEndDragOnAndroid();
}
}}
onScrollEndDrag={() => {
if (Platform.OS === 'android') {
this.props.onTouchEndEnableScrollOnAndroid(); // enables parent scroll
if (this.throttledOnScrollEndDragOnAndroid) {
this.throttledOnScrollEndDragOnAndroid.cancel();
}
}
}}
>
/* content */
</ScrollView> |
on all the scrollviews add prop nestedScrollEnabled, |
Same problem for me, with:
And when you try to scroll the child horizontally it scrolls the parent :( |
Oh No. I'm facing this as well. Nested horizontal scrollviews doesn't work on Android. I made this Snack with a reproduction: https://snack.expo.io/@brunolemos/nested-scrollview See full codeimport React from 'react'
import { ScrollView, ScrollViewProps, View, ViewProps } from 'react-native'
function App() {
return <Columns />
}
export default App
function Story(props: ViewProps) {
return (
<View
{...props}
style={[
{
width: 30,
height: 30,
borderRadius: 30 / 2,
backgroundColor: 'blue',
},
props.style,
]}
/>
)
}
function Stories(props: ScrollViewProps) {
return (
<ScrollView
horizontal
nestedScrollEnabled
{...props}
style={[
{
width: '100%',
maxHeight: 30 + 2 * 2,
backgroundColor: 'lightyellow',
},
props.style,
]}
>
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
<Story style={{ margin: 2 }} />
</ScrollView>
)
}
function Column(props: ViewProps) {
return (
<View
{...props}
style={[
{
paddingTop: 40,
width: 200,
height: '100%',
backgroundColor: 'lightgreen',
},
props.style,
]}
>
<Stories />
</View>
)
}
function Columns(props: ScrollViewProps) {
return (
<ScrollView
horizontal
nestedScrollEnabled
{...props}
style={[
{ width: '100%', height: '100%', backgroundColor: 'lightblue' },
props.style,
]}
>
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
<Column style={{ margin: 10 }} />
</ScrollView>
)
} |
@andreicoman11 @makovkastar @aamalric @astreet I checked the file blame and noticed you contributed a lot to the ReactHorizontalScrollView.java file. I was wondering (hoping) if you have any insight of what could be causing the issue above and what the fix could look like? |
@brunolemos My contribution was just about preventing scrolling with D-Pad key events when scroll is disabled, nothing to do with nested scroll with touch events...
|
I used React Native Swiper for this purpose.(Nested Scrolling)
EDIT:
React Native Swiper used ViewPager before the latest release,now it is not working in the newer version,One thing i have seen is that viewpager is replaced by ScrollView now,Is the answer suggested by @brunolemos a good to go solution for now?
…On Tue 8 Oct, 2019, 12:15 Alexandre AMALRIC, ***@***.***> wrote:
@brunolemos <https://github.com/brunolemos> My contribution was just
about preventing scrolling with D-Pad key events when scroll is disabled,
nothing to do with nested scroll with touch events...
Looking at the code I don't really see why it's not working, there's no
difference between vertical and horizontal scroll managers code for
Android, they both call:
ViewCompat.setNestedScrollingEnabled(view, value);
https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java#L157
https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java#L167
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#21436?email_source=notifications&email_token=AGIXKMVCYDBVR5RNE5CRYFDQNQUBTA5CNFSM4FYGYUC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEATA3HQ#issuecomment-539364766>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGIXKMXAMPFJ6IVEMKYFPVLQNQUBTANCNFSM4FYGYUCQ>
.
|
I found an easy workaround! If we use the import { ScrollView } from 'react-native'
import { ScrollView as GestureHandlerScrollView } from 'react-native-gesture-handler'
<ScrollView horizontal>
<GestureHandlerScrollView horizontal />
</ScrollVIew> You can have nested horizontal <FlatList {...props} renderScrollComponent={p => <GestureHandlerScrollView {...p} />} /> Updated the snack with this workaround: https://snack.expo.io/@brunolemos/nested-scrollview Maybe someone can check what |
@brunolemos nice one! Just tried on a real device and it worked! |
@brunolemos Thanks so much! It's scrolling but now the nestedScrollEnabled prop not works. Any idea? |
@cklinx why do you still need this prop if it's already scrolling correctly? also confirm that you are using the latest version of both |
For the ScrollViews to work as expected, nested or otherwise, you need to specify their boundaries. Boundaries are set in import { ScrollView } from 'react-native'
//
<ScrollView
style={{
width: "equal-to-or-less-than viewport width",
height: "equal-to-or-less-than viewport height"
}}
contentContainerStyle={{"..."}}
horizontal
>
<ScrollView
style={{
width: "lower-than Parent-ScrollView width",
height: "lower-than Parent-ScrollView height"
}}
contentContainerStyle={{"..."}}
>
</ScrollView>
</ScrollVIew>
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks a lot @isnotgood for pr #28138 which seems to implement this solution. I did not study much the ReactNativeGestureHandler I'm curious in the reason @isnotgood closed pr #28138, maybe performance limitation compared to ReactNativeGestureHandler?
Tomorrow I will give a further look in the ReactNativeGestureHandler implementation to see if I can understand and apply the same solution to HorizontalScrollView.java I am also considering creating a pull request to add information about this bug in the ScrollView docs so that the solution is easier to find. Thanks |
@fabriziobertoglio1987 there was no problem, I just closed it as there was no interest from maintainers 😄 Feel free to resurrect the PR on your own if you think it's worth the effort. |
I re-opened the PR with the permission of @isnotgood |
Just bumping in here to show people are still waiting for this fix. Can we get some maintainers to review this PR and get the fix in already. |
Encountering the same problem in react native 0.66.4. Any fix planned? |
I have tried to use ScrollView from import { ScrollView } from 'react-native-gesture-handler'
<ScrollView horizontal disableScrollViewPanResponder>
<ScrollView horizontal />
</ScrollVIew> |
i found this problem when we use nested scrollView to prevent horizontal or vertical scroll error but its doesnt work in android .so i make it like this (sry for my english )
|
Is there ever going to be a fix for this 2023 and still a bug |
here is the solution just add extra scrollView with different oriantation it will solve the issue ex |
Even that was not working, it seems there is a bug with respect to the Android gesture/swipe. If you are on a screen where an Android user can swipe back, the nested scroll layer is not accessible for most of the screen. While disabling swipe allows the nested scroll to work, ideally, there would be a way to fix them layering on top of each other incorrectly. It is not like Android is going to abandon nav gestures and users expect them at this point |
This works perfectly, thanks for the explanation! |
I tried the following schemes: |
Have you tried putting sizes on all ScrollViews as explained above? For me it works fine. |
I tried that, but it didn't work for me |
Can you show your code? |
We've finally are addressing this internally: #39097. Hopefully should be merged soon. |
Looks like this was merged. Any idea when it will go out or which version of RN will get it? I looked at the (CHANGELOG.md)[https://github.com/facebook/react-native/blob/main/CHANGELOG.md] and was not able to find any indication that this fix had gone live |
cc @jessebwr |
It will be in the 0.73.x release. Take a look at this commit tag. |
I just upgrade RN version to 0.73.1 and checked, but still horizontal doesn't work for the nested ScrollView in my code. Anyone has found it works horizontally? |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Environment
Binaries:
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.1.0.0 AI-173.4907809
Package:
"react": "16.5.0",
"react-native": "0.57.1",
Device Info:
Android Version: 5.0.2 LRX22G
Description
I think nestedScrollEnabled prop for ScrollView only work in vertical. I don't know what's wrong in my code or something else. Just change little bit in height and width length and add/remove nestedScrollEnabled.
Could anyone help me in this issue.
Reproducible Demo
VERTICAL
HORIZONTAL
The text was updated successfully, but these errors were encountered: