-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/tabs): enable hydration #28366
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
Conversation
3. We get a hydration error if `ng-content` is wrapped in another element. | ||
--> | ||
@if (_isServer) { | ||
<ng-content/> |
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.
why is this needed? I don't follow and would like to understand more. Why isn't this needed with CSR?
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 nodes that were projected have to match the nodes that are rendered out or the runtime will throw a hydration error. For the tabs specifically without the ng-content
we'll end up dropping the <mat-tab>
node and the anchor comment inside of it which are necessary for hydration. This workaround keeps the nodes around during SSR and then drops them once hydration is done.
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.
Ohh, I see what you're saying. I would have expected the mat-tab
to be resolved as well and have it's content SSR-ed as well. That seems like a surprising requirement for projection?
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 is a bit weird, but it's kinda expected. If the mat-tab
doesn't get projected, when the HTML makes it to the browser, it won't know that it existed when it was created on the server.
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 feels surprising to me that component authors would need to take care of that. It almost sounds like a bug to me that it works in CSR like that (talking about ContentChildren
matching without a ng-content`).
The change makes sense, but would love the comment to capture this as well, but no need to re-push. Also cc. @AndrewKushnir as some user-facing feedback on hydration potentially
87dde50
to
1fcb903
Compare
1fcb903
to
a130797
Compare
Adds a workaround that allows us to enable hydration in the tab group component.
a130797
to
cdf8980
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a workaround that allows us to enable hydration in the tab group component.