Skip to content

fix(material/sidenav): enable hydration #28340

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

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

crisbeto
Copy link
Member

Fixes that the sidenav was disabling hydration. This is problematic, because it essentially disables hydration for the entire app that is using the sidenav. The hydration errors had a couple of root causes:

  1. Focus trap anchors throw off hydration.
  2. We were moving the end sidenav manually so the visual order matches the DOM order for accessibility. Now this happens only on the client.

Fixes #27848.

@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release merge: preserve commits When the PR is merged, a rebase and merge should be performed labels Dec 29, 2023
@angular-robot angular-robot bot added the area: build & ci Related the build and CI infrastructure of the project label Dec 29, 2023
@crisbeto crisbeto force-pushed the 27848/sidenav-hydration branch 2 times, most recently from 528b7d9 to 04bba37 Compare December 29, 2023 15:04
Updates to the latest version of Angular which includes angular/angular#53246. It is necessary to get hydration working for the sidenav.
Fixes that the sidenav was disabling hydration. This is problematic, because it essentially disables hydration for the entire app that is using the sidenav. The hydration errors had a couple of root causes:
1. Focus trap anchors throw off hydration.
2. We were moving the end sidenav manually so the visual order matches the DOM order for accessibility. Now this happens only on the client.

Fixes angular#27848.
</mat-sidenav>
Main content
<button (click)="sidenav.toggle()">Click me</button>
<button (click)="startSidenav.toggle()">Toggle start</button>
<button (click)="endSidenav.toggle()">Toggle end</button>
</mat-sidenav-container>

<h2>Slide-toggle</h2>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: One thing I did play with in the past was to use Pupeteer and capture a screenshot of the SSR structure to ensure the initial "boilerplate" looks as expected. I wonder, do we also bother about this with these PRs or are we just ensuring no errors?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're just ensuring that there's no errors, but hydration errors actually aren't captured on the CI yet. Eventually it would be nice to add something (potentially Puppeteer or Webdriver) that opens the client-side-rendered page and checks that there are no JS errors.

@crisbeto crisbeto self-assigned this Jan 2, 2024
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jan 2, 2024
@crisbeto crisbeto merged commit 7a91d46 into angular:main Jan 2, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: build & ci Related the build and CI infrastructure of the project merge: preserve commits When the PR is merged, a rebase and merge should be performed P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(Sidenav): Support hydration
2 participants