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

Incorrect computed height and top value with flex shrink 1 and specific floating point values #1651

Open
1 task done
bbohlender opened this issue Apr 26, 2024 · 0 comments

Comments

@bbohlender
Copy link
Contributor

Report

Some kind of overflow happens if there are at least 3 children, each returning a .01 value in the measure function, and their summed height is greater than 32; all children must set flex-shrink to 1,, and the available height must be smaller than the summed margins.

I am using the npm yoga-layout/load version 3.0.4

Issues and Steps to Reproduce

const yoga = await loadYoga()
const config = yoga.Config.create()
config.setUseWebDefaults(true)
config.setPointScaleFactor(100)
const node = yoga.Node.create(config)
const child1 = yoga.Node.create(config)
const child2 = yoga.Node.create(config)
const child3 = yoga.Node.create(config)
node.setHeight(99)
node.insertChild(child1, 0)
node.setFlexDirection(FlexDirection.Column)
child1.setMargin(Edge.Bottom, 100)
child1.setMeasureFunc(() => ({ width: 1, height: 10.01 }))
child1.markDirty()
node.insertChild(child2, 1)
child2.setMeasureFunc(() => ({ width: 1, height: 10.01 }))
child2.markDirty()
node.insertChild(child3, 2)
child3.setMeasureFunc(() => ({ width: 1, height: 12.01 }))
child3.markDirty()
node.calculateLayout(undefined, undefined)
console.log(child1.getComputedHeight(), child1.getComputedTop())
console.log(child2.getComputedHeight(), child2.getComputedTop())
console.log(child3.getComputedHeight(), child3.getComputedTop())

Expected Behavior

console output should be

0 0
0 100
0 100

Actual Behavior

5248133 0
5248133 5248233
6296710 10496366

Changing the measure function of any child to a value retuning .02 returns the correct output
e.g. child1.setMeasureFunc(() => ({ width: 1, height: 10.02 }))

@bbohlender bbohlender changed the title Incorrect calculated position and size with flex shrink 1 and specific floating point values Incorrect computed height and top value with flex shrink 1 and specific floating point values Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants