Fix: allow dropdown parent links with URLs to navigate on click

- Only add data-bs-toggle=dropdown for items without real URL
- CSS hover handles dropdown display on desktop
- Enables Buscador General link to navigate to /buscar-apus/
This commit is contained in:
FrankZamora
2025-11-26 23:46:38 -06:00
parent 14e68031ac
commit 4cbde7e1b7

View File

@@ -111,7 +111,12 @@ class WP_Bootstrap_Navwalker extends Walker_Nav_Menu {
// Add dropdown-toggle class and attributes for parent items // Add dropdown-toggle class and attributes for parent items
if ($has_children && $depth === 0) { if ($has_children && $depth === 0) {
$atts['class'] .= ' dropdown-toggle'; $atts['class'] .= ' dropdown-toggle';
// Only add data-bs-toggle if no real URL (allows click navigation on desktop)
// CSS hover handles showing dropdown, data-bs-toggle only needed for mobile
$url = !empty($item->url) ? $item->url : '';
if (empty($url) || $url === '#' || $url === '#!') {
$atts['data-bs-toggle'] = 'dropdown'; $atts['data-bs-toggle'] = 'dropdown';
}
$atts['aria-expanded'] = 'false'; $atts['aria-expanded'] = 'false';
$atts['role'] = 'button'; $atts['role'] = 'button';
} }