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:
@@ -111,7 +111,12 @@ class WP_Bootstrap_Navwalker extends Walker_Nav_Menu {
|
||||
// Add dropdown-toggle class and attributes for parent items
|
||||
if ($has_children && $depth === 0) {
|
||||
$atts['class'] .= ' dropdown-toggle';
|
||||
$atts['data-bs-toggle'] = 'dropdown';
|
||||
// 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['aria-expanded'] = 'false';
|
||||
$atts['role'] = 'button';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user