Fix: use capture phase for navbar dropdown click handler
Added capture: true and stopImmediatePropagation() to ensure the click handler runs before Bootstrap's dropdown handlers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -314,6 +314,7 @@ window.addEventListener('scroll', updateActiveSection);
|
||||
// === NAVBAR DROPDOWN - Allow parent links to navigate on desktop ===
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.navbar .dropdown > .dropdown-toggle[href]').forEach(function(link) {
|
||||
// Use capture phase to run before Bootstrap's handlers
|
||||
link.addEventListener('click', function(e) {
|
||||
var href = this.getAttribute('href');
|
||||
// Only navigate if link has a real URL (not # or empty)
|
||||
@@ -322,10 +323,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (window.innerWidth >= 992) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
window.location.href = href;
|
||||
}
|
||||
// On mobile, let Bootstrap handle dropdown toggle
|
||||
}
|
||||
});
|
||||
}, true); // true = capture phase, runs before bubbling phase handlers
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user