Skip to content

Commit

Permalink
fix #395
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Oct 15, 2024
1 parent 9132c3a commit 16835d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/blocks/mega-menu/view.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import { store, getContext, getElement } from '@wordpress/interactivity';

[].slice
.call(
document.querySelectorAll(
'.wp-block-navigation-submenu__toggle + span.wp-block-navigation__submenu-icon'
)
)
.forEach( ( node ) => {
node.addEventListener( 'click', () => {
node.previousElementSibling.click();
} );
} );

const focusableSelectors = [
'a[href]',
'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',
Expand Down
17 changes: 17 additions & 0 deletions src/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,20 @@ document.addEventListener( 'DOMContentLoaded', () => {
observer.observe( target );
} );
} );

/**
* When “Open on click”, the submenu dropdown opens and closes when the toggle button is clicked.
*/
document.addEventListener( 'DOMContentLoaded', () => {
[].slice
.call(
document.querySelectorAll(
'.wp-block-navigation-submenu__toggle + span.wp-block-navigation__submenu-icon'
)
)
.forEach( ( node ) => {
node.addEventListener( 'click', () => {
node.previousElementSibling.click();
} );
} );
} );

0 comments on commit 16835d1

Please sign in to comment.