calculateBaseline(node) may return NaN if the baselineChild has not been measured
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18.9k
- Forks
- 1.6k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Demo JSX Code:
<Layout config={{useWebDefaults: false}}>
<Node style={{flexDirection: 'column'}}>
<Node style={{flexDirection: 'row', width: 200, padding: 10, alignItems:'baseline'}}>
<Node style={{ flexDirection: 'row', width: 100, height:100}}>
<Node />
</Node>
</Node>
</Node>
</Layout>
the yoga layout result : ⚠️⚠️⚠️the alignItems:'baseline' node got wrong lineHeight value of 0 ⚠️⚠️⚠️
in constrast, Chrome/Safari perform well as expected
this bug may resulting from wrong value returned by float calculateBaseline(const yoga::Node* node), if the baselineChild has not been measured, node->getLayout().measuredDimension(Dimension::Height) will return NaN value
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in yoga/algorithm/Baseline.cpp at calculateBaseline(const yoga::Node* node), then reproduce the JSX example from the issue in the Yoga playground. Inspect how an unmeasured baselineChild affects node->getLayout().measuredDimension(Dimension::Height). Done means the alignItems:'baseline' layout no longer produces a NaN-derived lineHeight of 0 and matches the expected browser behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100