-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Flex style ignored when tab view inside ScrollView #1349
Comments
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
Tested with versions listed above and results are the same |
I've narrowed down what seems to be causing the problem for me: In SceneView, the style object for the main view is
and the main body is
The position being absolute here means the children don't render, and the |
@paulsjohnson91 Thanks for investigating this. This issue seems to also be affecting the Material Top Tabs Navigator in React Navigation. Were you able to find a temporary solution? |
@DeveloperHarris unforunately I've not had time to investigate in detail, for now I've just forked the repo and removed both the position: absolute and the |
I found
in SceneView.tsx, however, I wasn't able to find the style with the position:absolute or undefined height. @paulsjohnson91 do you remember what file those were located in? Also, this occurs on android as well as ios, is it possible to update the tags? |
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
The position:absolute comes from the style object for the View in SceneView:
Specifically in the 'style' object above I'm struggling to see where this style object is populated however I believe it comes from the
I've now tested this with regular tab view not inside a tab view and removing the position option unfortunately doesn't work as it cuts off the bottom of the view. It looks like we need position to be absolute when the tabview is not in a scrollview and to be undefined when it is. I don't know if there's a better solution but maybe we could get a new TabView prop for |
Just noticed the same issue occurs in this issue raised last year, which is loading a tab view into a modal |
I'm running into this as well. "react-native": "0.68.2", |
Also running into this with react-navigation/material-top-tabs when trying to load it in a scrollview. @react-navigation/material-top-tabs : "^6.2.1", |
Also, have an issue with this. Does anyone have a current work around? Is there a better version of this library to downgrade to that is working? |
I have a TabView not within a ScrollView, but each tab has it's own FlatList within it. First time I Load the FlatList are cut off at the bottom. If I navigate away and come back then the FlatList recalculate and it adjusts to the full height of the page. I'm assuming this is the same issue. |
Downgrading to v2 seems to work for me. |
The
This style is from react-native-pager-view in utils.tsx |
Changing to
Solved it for me. It is not a proper fix though. |
Try adding
Here's the modified snack above showing it working: I spent a good amount of time myself trying to figure this one out, hope this helps! |
I was running into a similar problem myself, implementing I ended up using patch-package, overriding style={[
styles.route,
layout.width
? { width: layout.width }
: focused
? StyleSheet.absoluteFill
: null,
- style,
+ style?.[0]
// Only apply styles provided by sceneContainerStyle prop of TabView,
// ignoring absoluteFill from react-native-pager-view
]}
const styles = StyleSheet.create({
route: {
flex: 1,
- overflow: 'hidden',
+ overflow: 'visible',
// Default to visible
},
}); If |
Thank you! This worked for me. |
If you try to run it for iOS and Android you will see that this solution is still not working and it works only for Web |
@arisyo13 Can you please send some demo of that, not working for iOS or Android? The @azcarraga's solution with adding |
Closing this, since adding |
This is not working on android and IOS. Try scrolling on either device, you'll see it doesn't scroll - Better still, add an element below the scrollview. |
As @amireds said, this does not work in native. |
Does anyone got it working till now ? |
@okwasniewski This issue is not resolved. Under most conditions, there are still the same problems. |
@maximilize Let's reopen this. I will take a look at this one more time when I have time |
the same |
@okwasniewski just pinging to gauge if you think you'll have any time to look at this one again soon 🙏 |
@satya164 @okwasniewski Please could you look into this issue? Scrollview is not working when wrapped under tab view? |
Same issue but implemented using I have a ScrollView with a cover photo and the bottom of that are tabs:
|
Seeing this in I have a satisfactory workaround which is
|
This worked to me but I left overflow hidden as it was. I only changed style to style?.[0] |
Same with nested ScrollViews
|
I think what you are trying to achieve can be done using this library. Unfortunately at the moment we are not planning to support this. It's not possible to measure height of content inside of ScrollView (without some hacky workarounds), you can achieve it with this library by setting an explicit height. Also since we are trying to make this library easy to maintain (and contribute to) this does not correlate with the main idea to display simple tab view. Therefore I'm closing all issues regarding embedding tab-view inside of ScrollView. |
If this common usecase is no longer supported, should the README be updated with the above information? |
@dylmye The information about ScrollView not being supported, have been there the whole time. You can check it here: https://github.com/satya164/react-native-tab-view#avoid-rendering-tabview-inside-scrollview |
@okwasniewski "will disable the optimizations" is different from "doesn't show at all" though :) |
Current behavior
expo demo
When putting a tab view inside a ScrollView, the tabs contents don't show unless you put a static height value, it seems to ignore flex
Example
With rendered scene
If I were to set the tabview style to
height: 900
then it renders (although obviously with blank space underneath) but if I leave it as flex: 1 then nothing rendersExpected behavior
Flex should make the tab contents render in the remaining space of the screen
Reproduction
https://snack.expo.dev/66VUyv9e2
Platform
Environment
"dependencies": {
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-web": "0.17.1",
"react-native-tab-view": "3.1.1",
"react-native-pager-view": "5.4.9"
},
The text was updated successfully, but these errors were encountered: