DioxusLabs / DioxusLabs/taffy

Flexbox won't shrink after removing all children

Open
#830 2 comments 0 reactions 0 assignees View on GitHub
A-flexbox bug
Dominant language
Rust
Stars
3.6k
Forks
222
Avg merge
10h 41m
Merged PRs (30d)
40

Description

## `taffy` version

0.8.0

## Platform

Linux

## What you did

- Created a flexbox with mostly default parameters in column configuration; `size.w = 100%, size.h = auto`. No min or max size specified.
- Populated it with nodes that take up space.
- Computed layout.
- Removed all of the children.
- Computed layout again.

## What went wrong

I expected that the flexbox would shrink back to minimum size. Instead, it stayed the same size as if it still had items in it.

The expected result will actually occur if, after removing all children but before recomputing, you add a new child node which takes up no space.

## Additional information

Before removing children:
![Image](https://github.com/user-attachments/assets/a006a4f9-7bc4-4ad7-b45e-989054249ce9)

Incorrect result:
![Image](https://github.com/user-attachments/assets/a8c4aaa7-00b6-48e5-a3bd-6d935f2adee2)

Correct result (added a fake child node:)
![Image](https://github.com/user-attachments/assets/31e13d14-c04f-4fff-a803-c97c67ac1693)

If I had to guess there's probably a check somewhere that will refuse to recompute an area if there's no children to save time.

I can provide additional info about my setup if needed.

Contributor guide

Open the contributing guide

Research direction

Reproduce the described sequence in a minimal Rust example: compute a column flexbox with space-using children, remove them all, and compute again. Trace the layout recomputation for an empty container; done means it shrinks to its minimum size without adding a dummy child.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.