Skip to content

fix: hide the post navbar while scrolling#104

Open
AlejandroAkbal wants to merge 1 commit intomainfrom
auto-triage/17-feature-better-screen-utilization-dynamic-navigation-bar-hide
Open

fix: hide the post navbar while scrolling#104
AlejandroAkbal wants to merge 1 commit intomainfrom
auto-triage/17-feature-better-screen-utilization-dynamic-navigation-bar-hide

Conversation

@AlejandroAkbal
Copy link
Copy Markdown
Member

@AlejandroAkbal AlejandroAkbal commented Mar 14, 2026

Summary

Validation

  • pnpm install
  • pnpm exec prettier --check "components/layout/navigation/Navbar.vue"
  • pnpm exec nuxi typecheck (fails due to pre-existing repo-wide type issues plus missing @vue/language-core in the local environment)

Summary by CodeRabbit

  • New Features

    • Navbar now automatically hides when scrolling down on post pages and reappears when scrolling up, providing a better reading experience.
  • Style

    • Enhanced navbar transition animations for smoother visibility toggling.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 14, 2026

Walkthrough

The Navbar component now implements scroll-based visibility behavior on post pages. When users scroll down, the navbar hides; when scrolling up or near the top of the page, it becomes visible. The implementation uses requestAnimationFrame for performance optimization and tracks scroll delta to determine visibility state.

Changes

Cohort / File(s) Summary
Navbar Scroll Visibility
components/layout/navigation/Navbar.vue
Adds scroll-based navbar visibility with RAF-debounced scroll listener, delta-based directional tracking, intersection observer improvements for top detection, page-aware listener lifecycle management, and conditional CSS transforms for smooth visibility animations.

Sequence Diagram

sequenceDiagram
    participant User
    participant Window
    participant RAF as requestAnimationFrame
    participant Navbar
    participant IntersectionObserver

    User->>Window: Scrolls page
    activate Window
    Window->>Navbar: scroll event fires
    deactivate Window
    activate Navbar
    Navbar->>RAF: Schedule scroll handler
    RAF->>Navbar: Execute handler (batched)
    Navbar->>Navbar: Calculate scroll delta<br/>(currentScroll - lastScrollY)
    alt Scrolling down beyond threshold
        Navbar->>Navbar: isNavbarVisible = false
    else Scrolling up
        Navbar->>Navbar: isNavbarVisible = true
    else Near top (within threshold)
        Navbar->>Navbar: isNavbarVisible = true
    end
    Navbar->>Navbar: Update lastScrollY
    deactivate Navbar
    IntersectionObserver->>Navbar: Intersection event (at top)
    activate Navbar
    Navbar->>Navbar: Update isOnTop state
    deactivate Navbar
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: hide the post navbar while scrolling' directly matches the main objective of the changeset, which implements scroll-based navbar visibility toggling on post pages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch auto-triage/17-feature-better-screen-utilization-dynamic-navigation-bar-hide
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch auto-triage/17-feature-better-screen-utilization-dynamic-navigation-bar-hide
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/layout/navigation/Navbar.vue`:
- Around line 114-117: The navbar is only visually translated off-screen so its
interactive elements remain focusable; update the root element in Navbar.vue
(the element using the class bindings with isPostsPage, isOnTop,
isNavbarVisible) to set accessibility attributes when hidden: bind aria-hidden
and either inert (if supported) or tabindex behavior based on the same condition
that produces '-translate-y-full' (i.e., when isPostsPage && !isOnTop &&
!isNavbarVisible). Concretely, add :aria-hidden="isPostsPage && !isOnTop &&
!isNavbarVisible" and :inert="isPostsPage && !isOnTop && !isNavbarVisible"
(fallback: set tabindex="-1" on the root or programmatically remove focusability
of child interactive elements) so controls aren’t reachable by keyboard/screen
readers when the navbar is translated out.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 69498652-7af4-4877-87db-69d449d947c1

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc34fe and 4febbb4.

📒 Files selected for processing (1)
  • components/layout/navigation/Navbar.vue

Comment on lines +114 to +117
'-translate-y-full': isPostsPage && !isOnTop && !isNavbarVisible,
'translate-y-0': !isPostsPage || isOnTop || isNavbarVisible
}"
class="border-base-0/20 absolute inset-x-0 top-0 z-10 transition duration-200"
class="border-base-0/20 absolute inset-x-0 top-0 z-10 transform-gpu transition-[transform,background-color,box-shadow,backdrop-filter] duration-200 will-change-transform"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Hidden navbar remains focusable off-screen (a11y issue).

At Line 114, the navbar is only translated out of view. Menu controls can still receive focus while invisible, which is confusing for keyboard/screen-reader users.

♿ Suggested fix
     <div
+      :aria-hidden="isPostsPage && !isOnTop && !isNavbarVisible"
+      :inert="isPostsPage && !isOnTop && !isNavbarVisible"
       :class="{
         'fixed!': isPostsPage,
         'bg-base-1000/60 shadow-lg backdrop-blur-lg backdrop-saturate-200 md:border-b-2': isPostsPage && !isOnTop,
         '-translate-y-full': isPostsPage && !isOnTop && !isNavbarVisible,
-        'translate-y-0': !isPostsPage || isOnTop || isNavbarVisible
+        'translate-y-0': !isPostsPage || isOnTop || isNavbarVisible,
+        'pointer-events-none': isPostsPage && !isOnTop && !isNavbarVisible
       }"
       class="border-base-0/20 absolute inset-x-0 top-0 z-10 transform-gpu transition-[transform,background-color,box-shadow,backdrop-filter] duration-200 will-change-transform"
     >
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/layout/navigation/Navbar.vue` around lines 114 - 117, The navbar
is only visually translated off-screen so its interactive elements remain
focusable; update the root element in Navbar.vue (the element using the class
bindings with isPostsPage, isOnTop, isNavbarVisible) to set accessibility
attributes when hidden: bind aria-hidden and either inert (if supported) or
tabindex behavior based on the same condition that produces '-translate-y-full'
(i.e., when isPostsPage && !isOnTop && !isNavbarVisible). Concretely, add
:aria-hidden="isPostsPage && !isOnTop && !isNavbarVisible" and
:inert="isPostsPage && !isOnTop && !isNavbarVisible" (fallback: set
tabindex="-1" on the root or programmatically remove focusability of child
interactive elements) so controls aren’t reachable by keyboard/screen readers
when the navbar is translated out.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant