-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add top:0 to hiddenContentStyles #33289
base: master
Are you sure you want to change the base?
Conversation
📊 Bundle size reportUnchanged fixtures
|
Pull request demo site: URL |
… into hidden-styles-fix
What is the risk of regression making this fairly fundamental change? If folks have overridden this behavior, will they run into issues at runtime. CSS changes are some of the worst as they result in customer incidents not build failures. If this was a regression or an issue introduced recently perhaps the risk is lower. |
@JustSlone — valid questions, and I don't have a great answer. I feel pretty good about the change given that the intent of the style is that the element should be hidden, and if the element is effectively invisible, it shouldn't matter where it gets positioned. But I can't account for assumptions or overrides that a consumer might make. What's the philosophy here? I could hack around it in my own product to solve my own problem, but my preference is to fix the root cause and (hopefully) benefit everybody. Do we avoid making the right long-term fix because of the short term pain it will cause? |
Previous Behavior
hiddenContentStyles
setsposition: absolute
but does not specifytop
or any other positioning property. In this case, the element gets positioned wherever it would fall in the static flow. This can, in some cases cause the scroll height of the container to get inflated. E.g. consider the following pseudocode:You would expect
container
not to scroll, because its height (100px) matches its content (max-height: 100px
). Buthidden-div
gets defaulted to a position oftop: 200px
, meaningcontainer
has 200px of scrollable range (and the bottom 100px of it are empty space!)New Behavior
By specifying
top: 0
the hidden div is guaranteed to be positioned at the top of the container and won't affect the scroll height.