fix: dropdown service links not working from navbar
The smooth scroll handler was intercepting clicks on the "Servicios" dropdown toggle link (href="#servicios"), which on the landing page would find the #servicios section and call closeMenu(), immediately closing the menu before the user could click any service link. Fix: skip dropdown toggle links in smooth scroll handler, make dropdown toggle work via click on all devices (not just CSS :hover). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -407,7 +407,8 @@ p:last-child {
|
|||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar__item--dropdown:hover .navbar__link--dropdown i {
|
.navbar__item--dropdown:hover .navbar__link--dropdown i,
|
||||||
|
.navbar__item--dropdown.active .navbar__link--dropdown i {
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,27 +56,38 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ================================================================
|
// ================================================================
|
||||||
// 2. Mobile Dropdown Toggle
|
// 2. Dropdown Toggle (mobile + touch devices)
|
||||||
// ================================================================
|
// ================================================================
|
||||||
var dropdownItems = document.querySelectorAll('.navbar__item--dropdown');
|
var dropdownItems = document.querySelectorAll('.navbar__item--dropdown');
|
||||||
dropdownItems.forEach(function (item) {
|
dropdownItems.forEach(function (item) {
|
||||||
var link = item.querySelector('.navbar__link--dropdown');
|
var link = item.querySelector('.navbar__link--dropdown');
|
||||||
if (link) {
|
if (link) {
|
||||||
link.addEventListener('click', function (e) {
|
link.addEventListener('click', function (e) {
|
||||||
// Only toggle on mobile
|
// Always prevent default on the dropdown parent link
|
||||||
if (window.innerWidth <= 768) {
|
e.preventDefault();
|
||||||
e.preventDefault();
|
e.stopPropagation();
|
||||||
item.classList.toggle('active');
|
item.classList.toggle('active');
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Close dropdown when clicking outside (desktop)
|
||||||
|
document.addEventListener('click', function (e) {
|
||||||
|
dropdownItems.forEach(function (item) {
|
||||||
|
if (!item.contains(e.target)) {
|
||||||
|
item.classList.remove('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// ================================================================
|
// ================================================================
|
||||||
// 3. Smooth Scroll for Anchor Links
|
// 3. Smooth Scroll for Anchor Links
|
||||||
// ================================================================
|
// ================================================================
|
||||||
var anchorLinks = document.querySelectorAll('a[href^="#"]');
|
var anchorLinks = document.querySelectorAll('a[href^="#"]');
|
||||||
anchorLinks.forEach(function (link) {
|
anchorLinks.forEach(function (link) {
|
||||||
|
// Skip dropdown toggle links — they have their own handler
|
||||||
|
if (link.classList.contains('navbar__link--dropdown')) return;
|
||||||
|
|
||||||
link.addEventListener('click', function (e) {
|
link.addEventListener('click', function (e) {
|
||||||
var targetId = this.getAttribute('href');
|
var targetId = this.getAttribute('href');
|
||||||
if (targetId === '#') return;
|
if (targetId === '#') return;
|
||||||
|
|||||||
Reference in New Issue
Block a user