storybookjs / react-native

📓 Storybook for React Native!
https://storybook.js.org
MIT License
995 stars 142 forks source link

Sidebar doesn't display stories with react-native-tvos #568

Closed hazmah0 closed 2 months ago

hazmah0 commented 2 months ago

Describe the bug The sidebar doesn't display stories with react-native-tvos fork.

To Reproduce Steps to reproduce the behavior:

  1. Generate a new project npx degit chromaui/intro-storybook-react-native-template#main taskbox
  2. Install dependencies yarn install
  3. Run storybook in iOS yarn storybook:ios
  4. Open the sidebar

Expected behavior All stories should be loaded and displayed in the sidebar.

Screenshots With tvos fork: rn-tvos

With regular react-native rn

System:

Storybook Environment Info:

  System:
    OS: macOS 14.4
    CPU: (10) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.8.0 - ~/.nvm/versions/node/v20.8.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.8.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.8.0/bin/npm
    pnpm: 8.15.5 - ~/.nvm/versions/node/v20.8.0/bin/pnpm <----- active
  Browsers:
    Chrome: 123.0.6312.122
    Edge: 123.0.2420.97
    Safari: 17.4
  npmPackages:
    @storybook/addon-actions: 8.0.5 => 8.0.5
    @storybook/react: 8.0.5 => 8.0.5

Additional context react-native version: 0.73.6 react-native-tvos version: 0.73.6-1

dannyhw commented 2 months ago

What is the tvos fork? How would i test this?

hazmah0 commented 2 months ago

The repository is here https://github.com/react-native-tvos/react-native-tvos. It's basically a fork of react-native that adds support for tv platforms like tvOS and Android TV. Since Im building an app that should target both mobile and tv platforms Im currently using this fork.

The easiest way to test this would be to follow the official tutorial from the Storybook docs to generate a project, but instead use the tvos fork by modifying the dependencies: "react-native": "npm:react-native-tvos@^0.73.6-1"

My specific setup uses expo and these changes are documented here but should apply for non expo applications as well.

dannyhw commented 2 months ago

@hazmah0 can you provide me a repo with your specific setup which reproduces the problem?

hazmah0 commented 2 months ago

Sure, here you go.

  1. Clone the repo
  2. Install dependencies
  3. Open either ios or android emulator with storybook:ios or storybook:android
  4. Once the app is loaded, open the sidebar. There should be stories here but the sidebar is empty
dannyhw commented 2 months ago

@hazmah0 great thanks, will take a look soon

dannyhw commented 2 months ago

This seems like an issue with flatlist on the tvos fork, the items are there they just don't get the right height

dannyhw commented 2 months ago

@hazmah0 I found the issue, the flex:1 on the FlatList style seems to break it, if you patch this line in the @storybook/react-native package you can see it works

node_modules/@storybook/react-native/dist/index.js

var styles = import_react_native2.StyleSheet.create({
  sectionList: { flex: 1 }, <---
  sectionListContentContainer: {
    paddingBottom: 6,
  },
});

If you make it this instead it works

var styles = import_react_native2.StyleSheet.create({
  sectionList: { height: "100%"}, <----
  sectionListContentContainer: {
    paddingBottom: 6,
  },
});

Seems to me like a bug in the flatlist implementation on tv os react native

hazmah0 commented 2 months ago

Thanks for looking into this! I asked one of the maintainer of the tvos fork about this but they haven't tried running storybook unfortunately. Iv'e made them aware of the problem and the issue I created here so maybe they can pitch in on this.

dannyhw commented 2 months ago

I can also probably just change this flex:1 on sb side but ran out of time today, will take a look soon.

douglowder commented 2 months ago

@dannyhw you can close this if needed, see link above to the PR in the TV repo that fixes the issue.

dannyhw commented 2 months ago

@douglowder awesome, thanks!