Fixing Elementor Off-Canvas Anchor Links: The Solution You Need

Elementor’s Off-Canvas widget is a great tool for creating slide-out menus, but there’s one frustrating issue: anchor links don’t close the menu when clicked. Instead of smoothly navigating to the target section, the Off-Canvas menu stays open, blocking the content.

This is a known problem that many Elementor users have struggled with. We spent hours searching for a fix—some methods used to work but eventually broke. After extensive testing, we finally found a JavaScript fix that actually works.

If you’re using Elementor Off-Canvas and your anchor links aren’t closing the menu, here’s exactly how to fix it.

The Problem: Anchor Links Won’t Close the Off-Canvas Menu

By default, when you click an anchor link inside the Off-Canvas menu, Elementor:

  1. Scrolls to the section on the page.
  2. Keeps the menu open, covering the content.

Users expect the menu to close before scrolling to the anchor, but Elementor doesn’t handle this automatically.

This issue also existed with Elementor Popups, which many users used for slide-out menus before Off-Canvas was introduced. If you’re still using Popups for navigation, consider switching to Off-Canvas—but either way, you’ll still need this fix.

The Fix: Make Off-Canvas Anchor Links Close Before Scrolling

This JavaScript fix ensures that when an anchor link is clicked inside an Off-Canvas menu, Elementor will:
Close the menu first
Then scroll smoothly to the correct section

Copy & Paste This Code Into Your Site

If you’re still using Popups, consider migrating to Off-Canvas for a better experience—but either way, apply this fix to make anchor links work correctly.

Using Elementor Popups? Here’s How to Fix Anchor Links There Too

While we recommend switching to the Off-Canvas widget for better navigation performance, some users may prefer to stick with Elementor Popups for their slide-out menus.

If that’s you, you’ve probably run into the same issue:
❌ Clicking an anchor link inside a Popup doesn’t close the Popup.
❌ The page scrolls to the section, but the Popup remains open, blocking content.

After testing multiple fixes, we’ve found a JavaScript solution that actually works for Popups.

Copy & Paste This Code Into Your Site

How to Add This Fix to Your Website

1. Add the JavaScript Code to Your Site

  • In Elementor, open your template with the Off-Canvas element or Popup.
  • Drag in an HTML widget anywhere inside the template.
  • Paste the JavaScript fix inside the HTML widget.
  • Save and test your navigation.
  • Go to Elementor > Custom Code.
  • Click Add New → Set it to load in the footer.
  • Paste the JavaScript fix and save.

If you prefer a more structured approach, enqueue the script in your theme’s functions.php by adding:

Then, create a file named elementor-fix.js inside your theme’s /js/ folder and paste the JavaScript fix inside it.

2. Adjust for Your Site

  • Sticky Header? Adjust const headerOffset = 100; to match its height.
  • Popup Close Animation Delay? If your popup has a long close animation, increase setTimeout(() => { ... }, 500); to match the duration.

3. Test Your Anchor Links

  • Open your Popup menu and click an anchor link.
  • The popup should close first, then smoothly scroll to the section.

Why This Fix Works When Others Fail

We tested multiple fixes before landing on this one. Here’s why other common solutions didn’t work:

CSS-Only Fixes – Some users tried :target selectors, but they didn’t properly close the menu before scrolling.
Other JavaScript Workarounds – Many relied on .e-off-canvas[aria-hidden="false"], but failed to account for timing issues.
Our Fix properly detects anchor clicks, closes the menu, and then scrolls smoothly.

Final Thoughts: Off-Canvas vs. Popups—Which One Should You Use?

If you’re still using Elementor Popups for navigation, this JavaScript fix will solve the anchor link issue. However, for a better experience, we still recommend switching to Off-Canvas, since:

🔹 Off-Canvas is designed for menus → Popups weren’t built for navigation.
🔹 Better performance → Off-Canvas loads faster than Popups.
🔹 Easier customization → Works natively with Elementor’s Menu widget.
🔹 No extra bloat → Popups require more CSS/JavaScript.

But if you prefer sticking with Popups, now you have a reliable solution to ensure anchor links work the way they should.

If you found this guide helpful, let us know in the comments! 🚀

Leave a Reply

Your email address will not be published. Required fields are marked *