Skip to content

fix: enhance mobile overlay with instant-close functionality#35

Merged
suradet-ps merged 2 commits into
mainfrom
fix/mobile-overlay
May 25, 2026
Merged

fix: enhance mobile overlay with instant-close functionality#35
suradet-ps merged 2 commits into
mainfrom
fix/mobile-overlay

Conversation

@suradet-ps
Copy link
Copy Markdown
Owner

@suradet-ps suradet-ps commented May 25, 2026

Summary by Sourcery

Improve the mobile navigation overlay closing behavior to avoid sluggish transitions when navigating away from the page.

Bug Fixes:

  • Prevent sluggish navigation on mobile by instantly closing the overlay when a menu link is activated.

Enhancements:

  • Add an instant-close mode to the mobile overlay that disables transitions for faster perceived navigation.

Summary by CodeRabbit

  • New Features
    • Mobile navigation menu now closes instantly without animation delays when a link is selected or the hamburger button is toggled, providing a snappier and more responsive navigation experience on mobile devices.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rxdevnotes Ready Ready Preview, Comment May 25, 2026 4:26am

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 25, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the mobile navbar overlay so that link clicks trigger an instant-close mode (no transition) just before navigation, and ensures that subsequent openings restore normal animated behavior, including a forced reflow to reliably apply the instant-close style.

Sequence diagram for updated mobile overlay instant-close behavior

sequenceDiagram
  actor User
  participant HamburgerButton
  participant OverlayElement

  rect rgb(230,230,250)
    User->>HamburgerButton: click
    HamburgerButton->>OverlayElement: classList.remove(instant-close)
    HamburgerButton->>HamburgerButton: setMenuState(!isMenuOpen)
  end

  rect rgb(220,245,255)
    User->>OverlayElement: click link
    OverlayElement->>OverlayElement: classList.add(instant-close)
    OverlayElement->>OverlayElement: classList.remove(open)
    OverlayElement->>HamburgerButton: classList.remove(active)
    OverlayElement->>OverlayElement: inert = true
    OverlayElement->>OverlayElement: offsetHeight (force reflow)
  end
Loading

File-Level Changes

Change Details Files
Add an instant-close mode for the mobile overlay when a navigation link is clicked, and ensure transitions are reset on subsequent openings.
  • On hamburger click, explicitly remove the 'instant-close' class from the overlay before toggling the menu state so normal transitions apply when opening.
  • When handling link clicks that trigger navigation, add the 'instant-close' class to the overlay before closing to bypass transitions and make the overlay disappear immediately.
  • After closing the overlay in instant-close mode, force a reflow via 'void overlayElement.offsetHeight' to ensure the browser applies the updated styles and future openings animate correctly.
  • Define a '.mobile-overlay.instant-close' CSS rule that disables transitions and hides the overlay immediately using 'transition: none' and 'visibility: hidden'.
src/components/layout/Navbar.astro

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@suradet-ps, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 38 minutes and 32 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f66ceedc-7dbb-4dfe-81e7-d48c95f65d5e

📥 Commits

Reviewing files that changed from the base of the PR and between 2e314f9 and d5f1be7.

📒 Files selected for processing (1)
  • src/components/layout/Navbar.astro
📝 Walkthrough

Walkthrough

The mobile navigation overlay now supports immediate hiding via an instant-close class. When the menu opens, the class is removed to restore normal transitions. When a navigation link is clicked, the class is applied and a layout reflow is triggered before the overlay closes, ensuring instant visual feedback without transition delay.

Changes

Mobile overlay instant-close behavior

Layer / File(s) Summary
Instant-close overlay styling and toggle logic
src/components/layout/Navbar.astro
CSS adds .mobile-overlay.instant-close to disable transitions and hide immediately. Script removes the class on menu open, adds it on navigation link close, and forces reflow via offsetHeight to ensure the instant-close takes effect before state updates proceed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hop, click, and whoosh—the overlay flies,
No silly delay, just swift goodbyes,
A touch of the class, a reflow command,
The menu obeys with a snap so grand!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding instant-close functionality to the mobile overlay. It is concise, specific, and accurately reflects the primary purpose of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mobile-overlay

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

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider adding a short code comment near void overlayElement.offsetHeight; to explain that it’s intentionally forcing a reflow for the instant-close behavior, since this pattern can be confusing to future readers.
  • Review whether .mobile-overlay.instant-close needs !important on both transition and visibility, or whether scoping/selector specificity could be adjusted instead to avoid relying on !important.
  • Double-check all code paths that close or reopen the mobile overlay (e.g., clicking the overlay itself, escape key handlers) to ensure they consistently add/remove the instant-close class so that the overlay doesn’t get stuck in a no-transition state.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a short code comment near `void overlayElement.offsetHeight;` to explain that it’s intentionally forcing a reflow for the instant-close behavior, since this pattern can be confusing to future readers.
- Review whether `.mobile-overlay.instant-close` needs `!important` on both `transition` and `visibility`, or whether scoping/selector specificity could be adjusted instead to avoid relying on `!important`.
- Double-check all code paths that close or reopen the mobile overlay (e.g., clicking the overlay itself, escape key handlers) to ensure they consistently add/remove the `instant-close` class so that the overlay doesn’t get stuck in a no-transition state.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@suradet-ps suradet-ps merged commit 78ab804 into main May 25, 2026
9 checks passed
@suradet-ps suradet-ps deleted the fix/mobile-overlay branch May 25, 2026 04:29
github-actions Bot pushed a commit that referenced this pull request May 25, 2026
## [1.13.2](v1.13.1...v1.13.2) (2026-05-25)

### 🐛 Bug Fixes

* enhance mobile overlay with instant-close functionality ([#35](#35)) ([78ab804](78ab804))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.13.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant