react / react/yoga

calculating layout does not set all properties

Open
#1,158 1 comment 2 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

Code:

fun main()
    val root = YGNodeNew()
    YGNodeStyleSetWidth(root, 200f)
    YGNodeStyleSetHeight(root, 200f)

    val child = YGNodeNew()
    YGNodeStyleSetWidth(child, 100f)
    YGNodeStyleSetHeight(child, 100f)
    YGNodeStyleSetPosition(child, YGEdgeLeft, 10f)
    YGNodeStyleSetPosition(child, YGEdgeTop, 10f)
    YGNodeInsertChild(root, child, 0)

    YGNodeCalculateLayout(root, 200f, 200f, YGDirectionLTR)
    println(YGNodeLayoutGetLeft(child))
    println(YGNodeLayoutGetTop(child))
    println(YGNodeLayoutGetRight(child))
    println(YGNodeLayoutGetBottom(child))

    YGNodeFree(child)
    YGNodeFree(root)
}

Expected Behavior

it should print 10, 10, 110, 110 because right and bottom are 100 away from the other sides

Actual Behavior

it prints 10, 10, 10, 10 meaning the height and width are ignored

Link to Code

See above

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 at the YGNodeCalculateLayout entry point and the YGNodeLayoutGetLeft, YGNodeLayoutGetTop, YGNodeLayoutGetRight, and YGNodeLayoutGetBottom accessors shown in the reproduction. Reproduce the example and investigate why right and bottom print 10 instead of 110; done means the output is 10, 10, 110, 110.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.