react / react/yoga

[React-Native]: Combining flexWrap, alignItems & wrap leads to unwanted alignment

Open
#1,067 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Algorithm
Dominant language
C++
Stars
18.9k
Forks
1.6k
Avg merge
1m
Merged PRs (30d)
1

Description

Report

Issues and Steps to Reproduce

When margin is added to an item, inside a wrapping container, it should be ignored but it is taken into account during alignItems

Expected Behavior

In the following example the 2 colored square should be in the same spot

Actual Behavior

On the web (using react-native-web it works correctly)
On native, the second square is in the wrong spot cause it is centered inside height + margin instead of just height
i've added opacity to see what's happening

Link to Code

https://snack.expo.dev/@titozzz/yoga-issue-1067

Web:
Screenshot 2021-03-04 at 16 57 17
Native:
Screenshot_20210304-165704

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Expo Snack reproduction and compare the native result with react-native-web. Trace the wrapping container's alignItems behavior around item margins; done means the native layout places the two squares consistently with the expected result and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, react-native
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.