Free space is computed from min-clamped flex bases, so a growing item with minWidth gets its minimum plus a full share
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp, javascript
- Ambito
- frontend
Direzione di ricerca
Start in yoga/algorithm/FlexLine.cpp, focusing on calculateFlexLine, distributeFreeSpaceFirstPass, and distributeFreeSpaceSecondPass. Reproduce the supplied two cases with yoga-layout and trace how the clamped childFlexBasis affects free-space distribution. Done means the cases produce 40 / 80 and 200 / 50 / 50, matching the browser results.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Report
- I have searched existing issues and this is not a duplicate. #485 may share the root cause, but it also involves a percentage
flex-basisandmax-width; this is the minimal case.
Issues and Steps to Reproduce
When a growing item's minWidth is larger than its flex basis, Yoga computes the line's free space from the clamped basis and grows the item from there. CSS shares out free space from the unclamped flex base sizes, and applies the minimum only when the item would end up below it.
<div style="display: flex; width: 120px; height: 10px">
<div style="flex: 1; min-width: 30px"></div>
<div style="flex: 2"></div>
</div>
<div style="display: flex; width: 300px; height: 10px">
<div style="flex: 1; min-width: 200px"></div>
<div style="flex: 1"></div>
<div style="flex: 1"></div>
</div>
The same in yoga-layout 3.2.1, the version on npm:
import Yoga from 'yoga-layout';
function row(width, items) {
const root = Yoga.Node.create();
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setWidth(width);
root.setHeight(10);
const nodes = items.map(([grow, min], i) => {
const node = Yoga.Node.create();
node.setFlexGrow(grow);
node.setFlexShrink(1);
node.setFlexBasis(0);
if (min) node.setMinWidth(min);
root.insertChild(node, i);
return node;
});
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
return nodes.map((node) => node.getComputedWidth());
}
console.log(row(120, [[1, 30], [2, 0]])); // [60, 60]
console.log(row(300, [[1, 200], [1, 0], [1, 0]])); // [233, 34, 33]
setUseWebDefaults(true) on the config gives the same numbers.
Expected Behavior
40 / 80 and 200 / 50 / 50. Chrome, Firefox and Safari all give these.
Per CSS Flexbox 9.7, the initial free space subtracts the flex base sizes of the unfrozen items, not their hypothetical main sizes. Step 3 freezes an item at its hypothetical main size only when its flex factor is 0, or, when growing, when its base size is greater than its hypothetical size. An item whose min-width raises it above its base therefore stays flexible from base 0. In the first row, the free space is 120, shared 40 / 80, and 40 does not violate the 30px minimum. In the second row, the 300px is shared 100 each. The first item violates its 200px minimum, so it is frozen at 200 and the remaining 100 goes 50 / 50 to the other two.
Actual Behavior
60 / 60 and 233 / 34 / 33: the item with the minimum gets its minimum plus a full share, and its siblings lose the difference.
On main, calculateFlexLine (yoga/algorithm/FlexLine.cpp) adds boundAxisWithinMinAndMax(computedFlexBasis) to sizeConsumed. Both distributeFreeSpaceFirstPass and distributeFreeSpaceSecondPass start each item from that clamped childFlexBasis. So the free space comes out 30 short in the first row, and the 30 is added back on top of the item's share. I have not built main to confirm the numbers there, but the code paths are the ones above.
Link to Code
The snippets above are self-contained. We found this in react-x11, a React renderer that lays out with yoga-layout, while fixing a related bug where a stale minimum had been hiding it.
- Lingua principale
- C++
- Stelle
- 18.9k
- Fork
- 1.6k
- Merge medio
- 18h 48m
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di react/yoga
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
react/yoga#2027 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Stale computedFlexBasis is reused across layouts: a flex: 1 node keeps its previous size after relayout at a new root sizeForse già presa @mozzius l’ha presa 39 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
[Feature] flex-wrap: balanceAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
The Outdated Version prompt shows the release tag as unescaped HTMLForse già presa @on8st l’ha presa oggi. Apertabug good first issue GUI maintainer-review priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aethersdr/AetherSDR#6405 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bitcoin-core/gui-qml#1003 ·
I maintainer di solito rispondono entro 3 giorni
-
fails to compile with Qt6Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
[Bug]:设置的关于页面,“系统信息”部分排版异常Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
metasequoiaime/msime#7328 ·
I maintainer di solito rispondono entro 1 giorno
-
[Linux] --calibrate combined with --model silently falls through to plain re-setup (setup.py:4958)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno