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

Make getHeaderHeightWithoutNav() more robust to avoid errors seen in the wild. #6674

Closed
techanvil opened this issue Mar 2, 2023 · 5 comments
Labels
Exp: SP P1 Medium priority Type: Bug Something isn't working

Comments

@techanvil
Copy link
Collaborator

techanvil commented Mar 2, 2023

Feature Description

Since the release of version 1.95.0 a handful of errors have been reported from installed sites (four at the time of writing).

sitekit-1-95-0-prod-errors.png

These evidently relate to the work done via #6109 which was included in this release.

Although it's not been possible to recreate these issues in our testing we should add some defensive logic to getHeaderHeightWithoutNav() to prevent these errors.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The getHeaderHeightWithoutNav() function should be updated so that it doesn't return anything other than a positive number or zero.
  • It should make a best-effort attempt to calculate the correct height for the sticky Site Kit header & WordPress admin bar combination based on the information available.
  • It should return zero for any unexpected results.
  • Going forward, we should not see any more of these errors in the production logs.

Implementation Brief

  • Improve the check for header stickiness by checking the header's position style property via getComputedStyle().
  • Add some checks to ensure getHeaderHeightWithoutNav() cannot return anything but a finite positive integer or 0.
  • Refactor getHeaderHeightWithoutNav() to be more readable.
  • Add a guard at the point of using the return value of getHeaderHeightWithoutNav() as a failsafe - use Math.abs(), similar to how it's used in WidgetAreaRenderer.
  • Rename getHeaderHeightWithoutNav() and getHeaderHeight() to getStickyHeaderHeightWithoutNav() and getStickyHeaderHeight() to be more explicit.
  • Finish off the PR Make the getHeaderHeightWithoutNav() function more defensive. #6672 which implements the above.

Test Coverage

  • Add some tests for getStickyHeaderHeightWithoutNav() and backfill test coverage for getStickyHeaderHeight().

QA Brief

  • The bug described here should no longer occur.

I am running through the dashboard navigation tooltip tour and if you click 'back' on the final tip, a fatal error appears.

Changelog entry

  • Fix potential IntersectionObserver error in banner notifications.
@techanvil techanvil added P1 Medium priority Type: Bug Something isn't working Exp: SP labels Mar 2, 2023
@aaemnnosttv aaemnnosttv self-assigned this Mar 3, 2023
@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Mar 3, 2023

Moving forward to CR

@aaemnnosttv
Copy link
Collaborator

@techanvil I left a review on the PR that I reopened as a draft. Let's use that to inform a new IB, which could involve keeping the same PR (which is now against develop) if you'd like. Depending on what direction we take, it might make more sense to start fresh but I'm curious to get your thoughts.

@aaemnnosttv aaemnnosttv assigned techanvil and unassigned aaemnnosttv Mar 3, 2023
@techanvil
Copy link
Collaborator Author

@techanvil I left a review on the PR that I reopened as a draft. Let's use that to inform a new IB, which could involve keeping the same PR (which is now against develop) if you'd like. Depending on what direction we take, it might make more sense to start fresh but I'm curious to get your thoughts.

Thanks @aaemnnosttv, you raised some good points there. I've replied on the PR, and also made the discussed changes. I've also updated the IB - I think it makes sense to continue using this branch considering the amount of detailed discussion that has already taken place on it.

@techanvil techanvil assigned aaemnnosttv and unassigned techanvil Mar 9, 2023
@aaemnnosttv
Copy link
Collaborator

@techanvil there's a duplicate conflicting section for test coverage – I'll remove the older one.

IB ✅

@aaemnnosttv aaemnnosttv assigned techanvil and unassigned aaemnnosttv Mar 10, 2023
@techanvil techanvil assigned aaemnnosttv and unassigned techanvil Mar 13, 2023
@aaemnnosttv aaemnnosttv removed their assignment Mar 24, 2023
@mohitwp mohitwp self-assigned this Mar 27, 2023
@mohitwp
Copy link
Collaborator

mohitwp commented Mar 29, 2023

QA Update ✅

Recording.273.mp4

@mohitwp mohitwp removed their assignment Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Exp: SP P1 Medium priority Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants