Skip to content
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

[Documentation framework] - "page loaded" class doesn't always fire #4009

Closed
mcoker opened this issue May 7, 2024 · 0 comments · Fixed by #4012 or #4013
Closed

[Documentation framework] - "page loaded" class doesn't always fire #4009

mcoker opened this issue May 7, 2024 · 0 comments · Fixed by #4012 or #4013
Assignees
Labels

Comments

@mcoker
Copy link
Contributor

mcoker commented May 7, 2024

We added a .page-loaded class when all of the page assets have loaded as part of #3789

Looks like the class isn't always being added to the page. According to @evwilkin

well i can’t exactly say why it happens in incognito and not elsewhere, but i believe the TLDR is the window.load event listening is being added to the page after it’s already loaded. The listener is always there, but only triggers a “load” outside of Chrome incognito
hard to google what causes that and why it’s working in Chromium but not Chrome for me, but luckily I think there’s an easy fix - before we add the event listener we check document.readyState - if it’s “complete” we go ahead and add the class, if not we add the listener as we do now

And Evan said this was working for him

if (isFullscreenPreview) {
    isFullscreen = false;
    if (document?.readyState === 'complete') {
      document.body.classList.add('page-loaded');
    } else {
      window.addEventListener('load', () => {
        //append a class to the document body to indicate to screenshot/automated visual regression tools that the page has loaded
        document.body.classList.add('page-loaded');
      });
    }
  }

Once that is working, we'll want to add that to the core repo's backstop config as the readySelector, outlined in patternfly/patternfly#6602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Archived in project
2 participants