Skip to content

Commit

Permalink
Merge pull request #6646 from google/bug/6109-incorrect-view-notifica…
Browse files Browse the repository at this point in the history
…tions-followup

Fix calculation of the sticky header height to account for non-sticky header scenario.
  • Loading branch information
tofumatt authored Feb 27, 2023
2 parents 556db1e + f56c633 commit e74f480
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions assets/js/util/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ export function getHeaderHeight( breakpoint ) {
export function getHeaderHeightWithoutNav( breakpoint ) {
let headerHeight = 0;

// When the Joyride overlay is present, Site Kit's header is not sticky.
const isSiteKitHeaderSticky = ! document.querySelector(
'.react-joyride__overlay'
);

if ( ! isSiteKitHeaderSticky ) {
// If the Site Kit header is not sticky, we only need to calculate the height of the sticky WordPress admin bar.
// Furthermore, the WordPress admin bar is only sticky for breakpoints larger than BREAKPOINT_SMALL. If it's also not sticky then we can return a height of 0.
const wpAdminBar = document.querySelector( '#wpadminbar' );

if ( wpAdminBar && breakpoint !== BREAKPOINT_SMALL ) {
return wpAdminBar.offsetHeight;
}

return 0;
}

const header = document.querySelector( '.googlesitekit-header' );
if ( header ) {
headerHeight =
Expand Down

0 comments on commit e74f480

Please sign in to comment.