- This topic has 1 reply, 2 voices, and was last updated 5 months, 2 weeks ago by
Ying.
-
AuthorPosts
-
October 10, 2022 at 10:07 am #2369048
Heinrich
hi team,
played around with your megamenu settings and have a few issues.
we have accessibility code in place which enables the submenu only on click. the code is provided afterwards.
when we use the megamenu settings, i hove hover again but without the first subhirarchy shown? 4-columns are here this is what we want to have. now, when i click the arrow ther are only 3 columns, but correct with the first subhirarchy. you can check this out with the first menu topic: “seminare”can you give me a hint how to solve?
3 snippets in place:
1. remove filter:
add_action( ‘wp’, function() {
remove_filter( ‘nav_menu_item_title’, ‘generate_dropdown_icon_to_menu_link’, 10, 4 );
} );2. remove title attribut from skip-link:
add_filter(‘after_setup_theme’, function(){
remove_action( ‘generate_before_header’, ‘generate_do_skip_to_content_link’, 2 );
add_action( ‘generate_before_header’, function() {
printf( ‘%s‘,
esc_html__( ‘Skip to content’, ‘generatepress’ )
);
}, 2 );
});3. aria label – drop down menu:
add_filter( ‘nav_menu_item_title’, ‘generate_dropdown_icon_to_menu_link_with_aria_label’, 15, 4 );
function generate_dropdown_icon_to_menu_link_with_aria_label( $title, $item, $args, $depth ) {
$role = ‘presentation’;
$tabindex = ”;
$aria_attr = ‘aria-label=”klicken um in das Dropdown Menü zu gelangen”‘;if ( ‘click-arrow’ === generate_get_option( ‘nav_dropdown_type’ ) ) {
$role = ‘button’;
$tabindex = ‘ tabindex=”0″‘;
}if ( isset( $args->container_class ) && ‘main-nav’ === $args->container_class ) {
foreach ( $item->classes as $value ) {
if ( ‘menu-item-has-children’ === $value ) {
$arrow_direction = ‘down’;if ( ‘primary’ === $args->theme_location ) {
if ( 0 !== $depth ) {
$arrow_direction = ‘right’;if ( ‘left’ === generate_get_option( ‘nav_dropdown_direction’ ) ) {
$arrow_direction = ‘left’;
}
}if ( ‘nav-left-sidebar’ === generate_get_navigation_location() ) {
$arrow_direction = ‘right’;if ( ‘both-right’ === generate_get_layout() ) {
$arrow_direction = ‘left’;
}
}if ( ‘nav-right-sidebar’ === generate_get_navigation_location() ) {
$arrow_direction = ‘left’;if ( ‘both-left’ === generate_get_layout() ) {
$arrow_direction = ‘right’;
}
}if ( ‘hover’ !== generate_get_option( ‘nav_dropdown_type’ ) ) {
$arrow_direction = ‘down’;
}
}$arrow_direction = apply_filters( ‘generate_menu_item_dropdown_arrow_direction’, $arrow_direction, $args, $depth );
if ( ‘down’ === $arrow_direction ) {
$arrow_direction = ”;
} else {
$arrow_direction = ‘-‘ . $arrow_direction;
}$icon = generate_get_svg_icon( ‘arrow’ . $arrow_direction );
$title = $title . ‘<span role=”‘ . $role . ‘” ‘. $aria_attr .’ class=”dropdown-menu-toggle”‘ . $tabindex . ‘>’ . $icon . ‘</span>’;
}
}
}return $title;
}October 10, 2022 at 12:51 pm #2369174Ying
StaffCustomer SupportHi there,
Do you want the hover to work along with the click? Or do you only want the click-to-open dropdown?
Let me know! -
AuthorPosts
- You must be logged in to reply to this topic.