Repository navigation
Add overflow: clip, which keeps the automatic minimum size (#2106) (#60476) - #60476
Merged
Merged
Conversation
|
@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D135507378. |
… (react#60476) Summary: Pull Request resolved: react#60476 * Proposal: add overflow: clip, which keeps the automatic minimum size Why === A flex item that is a scroll container has an automatic minimum size of zero; any other has a content-based one (css-flexbox-1 §4.5). `overflow: hidden` makes a scroll container; `overflow: clip` clips without making one (css-overflow-3 §3.1: "the `visible` and `clip` values are known as the non-scrollable values", and "if neither axis computes to a scrollable value, the box is not a scroll container"). Yoga has `visible`, `hidden` and `scroll`. An app that only wants an item's content clipped, as React Native apps do with `overflow: 'hidden'` for rounded corners, has to say `hidden`, which with automatic minimum sizes on also gives up the item's minimum. This is a proposal because it adds a value to a public enum. How === `YGOverflowClip` clips and keeps the minimum: the automatic minimum is zero for `hidden` and `scroll` and content-based for `visible` and `clip`. Everywhere else Yoga only asks whether a box is `scroll`, so `clip` lays out as `hidden`. Clipping is the host's job, as for `hidden`. The value is not behind an erratum or an experimental feature: no existing value changes meaning, and only a node given the new value behaves differently. A `switch` over `YGOverflow` with no `default` gains a `-Wswitch` warning. React Native's switch in `YogaLayoutableShadowNode.cpp` handles `YGOverflowClip` alongside `hidden` and `scroll`, setting `FormsContentClip`. A native regression test verifies that the clip value sets the trait. Mapping the `overflow: 'clip'` style value to it is a separate React Native change. Test Plan ========= `python3 enums.py` regenerates the enum files with no change, and `yarn gentest` changes only the `YGAutoMinSizeTest` files, which gain `overflow_clip_item_keeps_content_size` next to the existing `overflow_hidden_item_shrinks_past_content`. `cmake --build tests/build && tests/build/yogatests` and `yarn format-check && yarn lint` pass. The new fixture cannot be built without the enum value. With `clip` treated as `hidden`, the item is 60 wide where Chrome has 120. `yarn gentest -h` leaves the tree clean, and `node ./scripts/clang-format.js --check` passes. The generated Java tests were not run, because the Gradle project has no unit-test source set; the Kotlin library compiles with the new enum value. The generated JavaScript tests were not run either, because they need Emscripten. Changelog: [General][Added] - Add `YGOverflowClip` to Yoga: an item that clips without being a scroll container keeps its automatic minimum size * Document overflow and what each value changes in layout Why === The website has no page for `overflow`, and the property affects layout in ways a reader cannot guess from its name: `hidden` and `scroll` make a scroll container, which has an automatic minimum size of zero (css-flexbox-1 §4.5), and `clip` does not. How === The new page `website/docs/styling/overflow.mdx` covers `visible`, `hidden`, `scroll` and `clip` as Yoga reads them: which make a scroll container, what that does to an item's automatic minimum size, and how a `scroll` node's content is measured. It states the limits: Yoga clips nothing, one value covers both axes, and automatic minimum sizes apply only with `MinSizeUndefinedInsteadOfAuto` off, so with a default config `clip` lays out exactly as `visible` and `hidden` do. The playground accepts `overflow: 'clip'`. Test Plan ========= The site builds with `docusaurus build`, which fails on a broken link, against a stub of the WebAssembly module, because the real build needs Emscripten. The playgrounds were therefore not run in a browser. `yarn tsc` in `website/` passes, and `prettier --check` and `eslint` pass on the changed TypeScript. The numbers on the page come from a program run against `libyogacore` built from this branch. Changelog: [Internal] * Deserialize overflow: clip in benchmark TreeDeserialization * Build the base with its own benchmark program when the PR's does not build The instruction-count job builds the base Yoga with the PR's benchmark program. When that program uses an API the PR adds, such as YGOverflowClip, the base build failed. Fall back to the base's own benchmark program, with a warning. --------- bypass-github-export-checks Yoga PR Reviewed By: vzaidman Differential Revision: D135507378 Signed-off-by: Pieter De Baets <pieterdb@meta.com>
vzaidman
approved these changes
Dec 4, 2026
vzaidman
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
javache
force-pushed
the
export-D135507378
branch
from
December 4, 2026 00:01
41f518d to
cc1ec89
Compare
meta-codesync Bot
pushed a commit
to meta/litho
that referenced
this pull request
Dec 4, 2026
Summary: X-link: react/react-native#60476 * Proposal: add overflow: clip, which keeps the automatic minimum size Why === A flex item that is a scroll container has an automatic minimum size of zero; any other has a content-based one (css-flexbox-1 §4.5). `overflow: hidden` makes a scroll container; `overflow: clip` clips without making one (css-overflow-3 §3.1: "the `visible` and `clip` values are known as the non-scrollable values", and "if neither axis computes to a scrollable value, the box is not a scroll container"). Yoga has `visible`, `hidden` and `scroll`. An app that only wants an item's content clipped, as React Native apps do with `overflow: 'hidden'` for rounded corners, has to say `hidden`, which with automatic minimum sizes on also gives up the item's minimum. This is a proposal because it adds a value to a public enum. How === `YGOverflowClip` clips and keeps the minimum: the automatic minimum is zero for `hidden` and `scroll` and content-based for `visible` and `clip`. Everywhere else Yoga only asks whether a box is `scroll`, so `clip` lays out as `hidden`. Clipping is the host's job, as for `hidden`. The value is not behind an erratum or an experimental feature: no existing value changes meaning, and only a node given the new value behaves differently. A `switch` over `YGOverflow` with no `default` gains a `-Wswitch` warning. React Native's switch in `YogaLayoutableShadowNode.cpp` handles `YGOverflowClip` alongside `hidden` and `scroll`, setting `FormsContentClip`. A native regression test verifies that the clip value sets the trait. Mapping the `overflow: 'clip'` style value to it is a separate React Native change. Test Plan ========= `python3 enums.py` regenerates the enum files with no change, and `yarn gentest` changes only the `YGAutoMinSizeTest` files, which gain `overflow_clip_item_keeps_content_size` next to the existing `overflow_hidden_item_shrinks_past_content`. `cmake --build tests/build && tests/build/yogatests` and `yarn format-check && yarn lint` pass. The new fixture cannot be built without the enum value. With `clip` treated as `hidden`, the item is 60 wide where Chrome has 120. `yarn gentest -h` leaves the tree clean, and `node ./scripts/clang-format.js --check` passes. The generated Java tests were not run, because the Gradle project has no unit-test source set; the Kotlin library compiles with the new enum value. The generated JavaScript tests were not run either, because they need Emscripten. Changelog: [General][Added] - Add `YGOverflowClip` to Yoga: an item that clips without being a scroll container keeps its automatic minimum size * Document overflow and what each value changes in layout Why === The website has no page for `overflow`, and the property affects layout in ways a reader cannot guess from its name: `hidden` and `scroll` make a scroll container, which has an automatic minimum size of zero (css-flexbox-1 §4.5), and `clip` does not. How === The new page `website/docs/styling/overflow.mdx` covers `visible`, `hidden`, `scroll` and `clip` as Yoga reads them: which make a scroll container, what that does to an item's automatic minimum size, and how a `scroll` node's content is measured. It states the limits: Yoga clips nothing, one value covers both axes, and automatic minimum sizes apply only with `MinSizeUndefinedInsteadOfAuto` off, so with a default config `clip` lays out exactly as `visible` and `hidden` do. The playground accepts `overflow: 'clip'`. Test Plan ========= The site builds with `docusaurus build`, which fails on a broken link, against a stub of the WebAssembly module, because the real build needs Emscripten. The playgrounds were therefore not run in a browser. `yarn tsc` in `website/` passes, and `prettier --check` and `eslint` pass on the changed TypeScript. The numbers on the page come from a program run against `libyogacore` built from this branch. Changelog: [Internal] * Deserialize overflow: clip in benchmark TreeDeserialization * Build the base with its own benchmark program when the PR's does not build The instruction-count job builds the base Yoga with the PR's benchmark program. When that program uses an API the PR adds, such as YGOverflowClip, the base build failed. Fall back to the base's own benchmark program, with a warning. --------- bypass-github-export-checks Yoga PR Reviewed By: vzaidman Differential Revision: D135507378 fbshipit-source-id: 4fb1f4feae4d69769c71bc3512643772a861d292 Co-authored-by: intergalacticspacehighway <nishanbende@gmail.com>
Collaborator
|
This pull request was successfully merged by @javache in 82ae057 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Why
A flex item that is a scroll container has an automatic minimum size of zero; any other has a content-based one (css-flexbox-1 §4.5).
overflow: hiddenmakes a scroll container;overflow: clipclips without making one (css-overflow-3 §3.1: "thevisibleandclipvalues are known as the non-scrollable values", and "if neither axis computes to a scrollable value, the box is not a scroll container").Yoga has
visible,hiddenandscroll. An app that only wants an item's content clipped, as React Native apps do withoverflow: 'hidden'for rounded corners, has to sayhidden, which with automatic minimum sizes on also gives up the item's minimum.This is a proposal because it adds a value to a public enum.
How
YGOverflowClipclips and keeps the minimum: the automatic minimum is zero forhiddenandscrolland content-based forvisibleandclip. Everywhere else Yoga only asks whether a box isscroll, socliplays out ashidden. Clipping is the host's job, as forhidden.The value is not behind an erratum or an experimental feature: no existing value changes meaning, and only a node given the new value behaves differently. A
switchoverYGOverflowwith nodefaultgains a-Wswitchwarning. React Native's switch inYogaLayoutableShadowNode.cpphandlesYGOverflowClipalongsidehiddenandscroll, settingFormsContentClip. A native regression test verifies that the clip value sets the trait. Mapping theoverflow: 'clip'style value to it is a separate React Native change.Test Plan
python3 enums.pyregenerates the enum files with no change, andyarn gentestchanges only theYGAutoMinSizeTestfiles, which gainoverflow_clip_item_keeps_content_sizenext to the existingoverflow_hidden_item_shrinks_past_content.cmake --build tests/build && tests/build/yogatestsandyarn format-check && yarn lintpass.The new fixture cannot be built without the enum value. With
cliptreated ashidden, the item is 60 wide where Chrome has 120.yarn gentest -hleaves the tree clean, andnode ./scripts/clang-format.js --checkpasses. The generated Java tests were not run, because the Gradle project has no unit-test source set; the Kotlin library compiles with the new enum value. The generated JavaScript tests were not run either, because they need Emscripten.Changelog:
[General][Added] - Add
YGOverflowClipto Yoga: an item that clips without being a scroll container keeps its automatic minimum sizeWhy
The website has no page for
overflow, and the property affects layout in ways a reader cannot guess from its name:hiddenandscrollmake a scroll container, which has an automatic minimum size of zero (css-flexbox-1 §4.5), andclipdoes not.How
The new page
website/docs/styling/overflow.mdxcoversvisible,hidden,scrollandclipas Yoga reads them: which make a scroll container, what that does to an item's automatic minimum size, and how ascrollnode's content is measured. It states the limits: Yoga clips nothing, one value covers both axes, and automatic minimum sizes apply only withMinSizeUndefinedInsteadOfAutooff, so with a default configcliplays out exactly asvisibleandhiddendo. The playground acceptsoverflow: 'clip'.Test Plan
The site builds with
docusaurus build, which fails on a broken link, against a stub of the WebAssembly module, because the real build needs Emscripten. The playgrounds were therefore not run in a browser.yarn tscinwebsite/passes, andprettier --checkandeslintpass on the changed TypeScript. The numbers on the page come from a program run againstlibyogacorebuilt from this branch.Changelog: [Internal]
Deserialize overflow: clip in benchmark TreeDeserialization
Build the base with its own benchmark program when the PR's does not build
The instruction-count job builds the base Yoga with the PR's benchmark program.
When that program uses an API the PR adds, such as YGOverflowClip, the base
build failed. Fall back to the base's own benchmark program, with a warning.
bypass-github-export-checks Yoga PR
Reviewed By: vzaidman
Differential Revision: D135507378
Signed-off-by: Pieter De Baets pieterdb@meta.com