Skip to content
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

flexGrow: 1 inside alignItems: <non-stretch> covers siblings #41140

Open
szmarczak opened this issue Oct 21, 2023 · 5 comments
Open

flexGrow: 1 inside alignItems: <non-stretch> covers siblings #41140

szmarczak opened this issue Oct 21, 2023 · 5 comments
Labels

Comments

@szmarczak
Copy link

szmarczak commented Oct 21, 2023

Description

image

Android:

394606776_754158426725135_4092957756381229100_n

React Native Version

0.72.5

Output of npx react-native info

> npx react-native info
info Fetching system and libraries information...
System:
  OS: Windows 10 10.0.22621
  CPU: "(12) x64 AMD Ryzen 5 5600 6-Core Processor              "
  Memory: 16.28 GB / 31.91 GB
Binaries:
  Node:
    version: 20.2.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 9.7.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.5.33424.131 (Visual Studio Community 2022)
Languages:
  Java:
    version: 11.0.20.1
    path: C:\Program Files\Eclipse Adoptium\jdk-11.0.20.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.5
    wanted: 0.72.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to reproduce

import { View, Text } from 'react-native';

export default function App() {
  return (
    <View>
			<View style={{ alignItems: 'center', }}>
        <View style={{ backgroundColor: 'red' }}>
          <View style={{ flexGrow: 1 }}>
            <Text>foo</Text>
          </View>
        </View>

        <Text>foo</Text>
        <Text>foo</Text>
        <Text>foo</Text>
        <Text>foo</Text>
			</View>
    </View>
  );
}

Snack, screenshot, or link to a repository

https://snack.expo.dev/@szmarczak/blessed-violet-cheese

@github-actions
Copy link

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.72.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@szmarczak szmarczak changed the title flexGrow: 1 inside ScrollView covers the rest of children flexGrow: 1 inside alignItems: 'center' covers the rest of children Oct 21, 2023
@szmarczak
Copy link
Author

szmarczak commented Oct 21, 2023

I tried working around this but it seems that alignSelf is affected as well:

import { View, Text } from 'react-native';

export default function App() {
  return (
    <View>
			<View style={{  }}>
        <View style={{ backgroundColor: 'red', alignSelf: 'center' }}>
          <View style={{ flexGrow: 1 }}>
            <Text>foo</Text>
          </View>
        </View>

        <Text>foo</Text>
        <Text>foo</Text>
        <Text>foo</Text>
        <Text>foo</Text>
			</View>
    </View>
  );
}

flex-start, flex-end, baseline don't work too.

@szmarczak szmarczak changed the title flexGrow: 1 inside alignItems: 'center' covers the rest of children flexGrow: 1 inside alignItems: non-stretch covers the rest of children Oct 21, 2023
@szmarczak
Copy link
Author

Working workaround:

const Center = ({children}) => {
  return (
    <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
    <View>
      {children}
    </View>
  </View>
  );
};

@szmarczak szmarczak changed the title flexGrow: 1 inside alignItems: non-stretch covers the rest of children flexGrow: 1 inside alignItems: <non-stretch> covers other children Oct 21, 2023
@szmarczak szmarczak changed the title flexGrow: 1 inside alignItems: <non-stretch> covers other children flexGrow: 1 inside alignItems: <non-stretch> covers siblings Oct 21, 2023
@rafalmilichiewicz
Copy link

Also present on iOS

@cortinico cortinico added the Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. label Oct 24, 2023
@NickGerleman
Copy link
Contributor

Is this specific to text children?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants