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

EPS-482: Navigation menu not redirecting correctly #915

Merged
merged 6 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ To access the advanced features and premium widgets, you’ll need to upgrade to
## Changelog ##

### 2.1.0.1 ###
- Fix: Navigation Menu - Anchor links now correctly scroll to sections/container when submenu items with IDs are clicked.
- Fix: "Function map_meta_cap called incorrectly" notice appearing for logged out users when shortcode executed manually.
- Fix: Deprecated constant FILTER_SANITIZE_STRING replaced to ensure compatibility with PHP
- Fix: Deprecated constant FILTER_SANITIZE_STRING replaced to ensure compatibility with PHP.

### 2.1.0 ###
- New: Added NPS Survey to gather your valuable feedback for Ultimate Addons for Elementor.
Expand Down
15 changes: 13 additions & 2 deletions inc/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,26 @@
function _handleSinglePageMenu( id, layout ) {
$( '.elementor-element-' + id + ' ul.hfe-nav-menu li a' ).on(
'click',
function () {
function ( event ) {
var $this = $( this );
var link = $this.attr( 'href' );
var linkValue = '';
if ( link.includes( '#' ) ) {

// Optimized code to redirect to submenu-ids on traverse.
if ( link.includes( '#' ) && link.charAt(0) === '#' ) { // Check if the link is an anchor link.
event.preventDefault();
var index = link.indexOf( '#' );
linkValue = link.slice( index + 1 );
}
if ( linkValue.length > 0 ) {
var targetSection = $( '#' + linkValue );

if ( targetSection.length ) { // Check if the target section exists.
$('html, body').animate({
scrollTop: targetSection.offset().top
}, 800);
}

if ( 'expandible' == layout ) {
$( '.elementor-element-' + id + ' .hfe-nav-menu__toggle' ).trigger( "click" );
if ($this.hasClass( 'hfe-sub-menu-item' )) {
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ To access the advanced features and premium widgets, you’ll need to upgrade to
== Changelog ==

= 2.1.0.1 =
- Fix: Navigation Menu - Anchor links now correctly scroll to sections/container when submenu items with IDs are clicked.
- Fix: "Function map_meta_cap called incorrectly" notice appearing for logged out users when shortcode executed manually.
- Fix: Deprecated constant FILTER_SANITIZE_STRING replaced to ensure compatibility with PHP
- Fix: Deprecated constant FILTER_SANITIZE_STRING replaced to ensure compatibility with PHP.

= 2.1.0 =
- New: Added NPS Survey to gather your valuable feedback for Ultimate Addons for Elementor.
Expand Down