-
Notifications
You must be signed in to change notification settings - Fork 45.9k
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
Fix: LegacyHidden should not toggle effects #21928
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. Legacy hidden does toggle visibility, right? It's just not supposed to run layout effects when visibility changes.
Wouldn't removing this flag also prevent it from calling
hideOrUnhideAllChildren
later?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to hide stuff but I removed that behavior, because some existing code in FB was relying on the ability to override the style of
<div hidden={true} />
with a CSS class by settingdisplay: block
. Which doesn't work if React sets an inline style, which is whathideOrUnhideAllChildren
does.So instead in www we always render LegacyHidden via a userspace abstraction that wraps it in a DOM node, and sets
hidden=true
on that DOM node. This also worked around the insertion problem fixed by this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the
hidden
attribute works is browser's have a built-in stylesheet with this rule:That has pretty low precedence in CSS, so a user stylesheet can override it by setting
display
to something else.But the way Offscreen/Suspense works is by setting the
display
property directly on the node with an inline style. We also use!important
. So it can't be overridden.We don't actually want to support overriding the style like this, but some code was already relying on it, so I added the LegacyHidden type to prevent a regression and unblock the Lanes refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Looking at how the
Visibility
flag is used, it's what ensureshideOrUnhideAllChildren
is called which in turn is what callshideInstance
orunhideInstance
in the host config, so this change seemed like it would break that.Ah, so basically FB is the only ones that will ever use this component, and we'll eventually clean it up there too? (So this API doesn't need to work outside of the FB context?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah exactly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear I mean I removed this behavior like last year :D