Skip to content

Commit

Permalink
Avoid CLS issue on mobile #10305
Browse files Browse the repository at this point in the history
On mobile the menu is closed by default. Before, it was opened, then
very quickly closed. That leads to a huge Cumulative Layout Shift issue.

On http://localhost:4201/, Lighthouse reported a CLS of 0.343,
now it is 0.
  • Loading branch information
PowerKiKi committed Apr 3, 2024
1 parent 73d13c8 commit f0577a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion projects/natural/src/lib/modules/sidenav/sidenav.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ export class NaturalSidenavService extends NaturalAbstractController {
assert(this.openedStorageKeyWithName);
const value = this.sessionStorage.getItem(this.openedStorageKeyWithName);

return value === null || value === 'true';
if (value === null) {
return !this.isMobileView();
} else {
return value === 'true';
}
}

/**
Expand Down

0 comments on commit f0577a7

Please sign in to comment.