Skip to content

fix: navigation bar flickering on scroll - #2396

Open
vforvaishnavi4510-boop wants to merge 2 commits into
piyushgarg-dev:mainfrom
vforvaishnavi4510-boop:fix/navigation-bar-flicker
Open

vforvaishnavi4510-boop wants to merge 2 commits into
piyushgarg-dev:mainfrom
vforvaishnavi4510-boop:fix/navigation-bar-flicker

Conversation

@vforvaishnavi4510-boop

@vforvaishnavi4510-boop vforvaishnavi4510-boop commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes #2395
Top Navigation Bar Flickers/Disappears While Scrolling on the Home Page

Problem

When scrolling past ~80px, the header rapidly flickered between its normal and "shrunk" states.

Root cause

The base .header and .header__shrink classes had different layout properties:

Property .header (base) .header__shrink
position static (default) sticky
height 94px (60px on mobile) 80px

Every time the scroll handler toggled the class at the 80px threshold, the header moved in and out of the document flow and changed height. This shifted the page content, which moved scrollY back across the threshold, which toggled the class again. The result was a feedback loop that appeared as flickering.

Changes

header.module.css

  • .header is now position: sticky with top: 0 and z-index: 1000 in both states, so the layout never changes.
  • .header__shrink now only applies a box-shadow (visual change only, no layout change).
  • Added transition: box-shadow 0.3s ease for a smooth shadow fade.
  • Fixed an invalid box-shadow declaration. var(--site-theme-color) 44 is not valid CSS, so the shadow was being ignored. It now uses color-mix(in srgb, var(--site-theme-color) 27%, transparent).
  • Removed the duplicate .header rule and the duplicate max-width: 768px media query.

Header.jsx

  • Added hysteresis to headerFunc: the header__shrink class is added when scrollY > 100 and removed when scrollY < 20. A small layout shift or scroll bounce can no longer flip the state back and forth.

Testing

Tested manually, as this is a visual/scroll behavior fix:

  • Scrolled slowly past 100px on desktop: no flicker, shadow fades in
  • Scrolled back up past 20px: shadow fades out, no flicker
  • Checked widths below 992px and 768px: header height stays stable
  • Opened the mobile menu: the overlay still covers the full screen
  • Hard refresh while already scrolled: the correct state is applied

Screenshots / Recording

VN20261117_102101.mp4

| Before |

before.mp4

Notes

  • Only Header.jsx and header.module.css are changed. No new dependencies.
  • color-mix() is supported in all current major browsers (Chrome 111+, Safari 16.2+, Firefox 113+). If older browser support is needed, it can be replaced with a hardcoded rgba/hex-alpha shadow color.

@vercel

vercel Bot commented Nov 17, 2026

Copy link
Copy Markdown

@vforvaishnavi4510-boop is attempting to deploy a commit to the Piyush Garg's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the bug Something isn't working label Nov 17, 2026
@vforvaishnavi4510-boop vforvaishnavi4510-boop changed the title Fix/navigation bar flicker fix: navigation bar flickering on scroll Nov 17, 2026
@vforvaishnavi4510-boop

Copy link
Copy Markdown
Author

“Ready for review. The Vercel check needs team authorization to deploy a preview.”

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Top Navigation Bar Flickers/Disappears While Scrolling on the Home Page

1 participant