Skip to content

Commit e7fce44

Browse files
authored
Merge pull request #237 from OpenSourceOrg/fix/t51eng-2081-dismiss-state-develop
Fix the dismissed state stranding mega menu panels (develop)
2 parents 2bde3e7 + 659a7a4 commit e7fce44

8 files changed

Lines changed: 21 additions & 27 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'f179507f6e77a9763a06');
1+
<?php return array('dependencies' => array(), 'version' => '42979785231fcdbb3f33');

‎themes/osi/assets/js/build/theme.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎themes/osi/assets/js/src/theme/mega-menu.js‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ if ( header && megaItems.length ) {
6161
if ( suppressOpen || ! desktopNav.matches ) {
6262
return;
6363
}
64+
item.classList.remove( 'is-dismissed' );
6465
window.clearTimeout( closeTimer );
6566
megaItems.forEach( ( other ) => {
6667
if ( other !== item ) {
@@ -136,11 +137,12 @@ if ( header && megaItems.length ) {
136137

137138
// a panel opened by hover holds focus nowhere, so Escape has to be caught globally
138139
document.addEventListener( 'keydown', ( event ) => {
139-
if (
140-
'Escape' === event.key &&
141-
document.querySelector( '.nav-main--menu > .menu-item.megamenu.is-open' )
142-
) {
143-
megaItems.forEach( dismiss );
140+
if ( 'Escape' !== event.key ) {
141+
return;
142+
}
143+
const openItem = document.querySelector( '.nav-main--menu > .menu-item.megamenu.is-open' );
144+
if ( openItem ) {
145+
dismiss( openItem );
144146
}
145147
} );
146148

‎themes/osi/assets/scss/_6_components.navigation.scss‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,6 @@ footer {
307307
padding: .5em;
308308
}
309309

310-
.menu-item {
311-
&.current-menu-item > a, &.current-menu-parent > a, &.current-menu-ancestor > a {
312-
text-decoration: none;
313-
}
314-
}
315-
316310
}
317311

318312
& > .menu-item > a:hover,

‎themes/osi/inc/class-osi-megamenu-walker.php‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ public function walk( $elements, $max_depth, ...$args ) { // phpcs:ignore Squiz.
6969
* to stay out of their sizing, and column flow would then fill that whole span before
7070
* wrapping (@see T51ENG-2081).
7171
*
72-
* @param array $atts HTML attributes for the menu item's li.
73-
* @param WP_Post $menu_item Menu item data object.
74-
* @param stdClass $args An object of wp_nav_menu() arguments.
75-
* @param integer $depth Depth of menu item.
72+
* @param array $atts HTML attributes for the menu item's li.
73+
* @param WP_Post|null $menu_item Menu item data object.
74+
* @param stdClass|null $args An object of wp_nav_menu() arguments.
75+
* @param integer $depth Depth of menu item.
7676
*
7777
* @return array
7878
*/
79-
public function add_panel_placement( array $atts, WP_Post $menu_item, stdClass $args, int $depth ): array {
80-
if ( 1 !== $depth || null === $this->current_parent || 'primary_navigation' !== ( $args->theme_location ?? '' ) ) {
79+
public function add_panel_placement( $atts, $menu_item = null, $args = null, $depth = 0 ) { // phpcs:ignore Squiz.Commenting.FunctionComment.ScalarTypeHintMissing,Squiz.Commenting.FunctionComment.TypeHintMissing -- untyped on purpose, see template-functions.php
80+
if ( ! is_array( $atts ) || 1 !== (int) $depth || null === $this->current_parent
81+
|| 'primary_navigation' !== ( is_object( $args ) ? ( $args->theme_location ?? '' ) : '' ) ) {
8182
return $atts;
8283
}
8384

‎themes/osi/inc/template-functions.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ function osi_supporters_shortcode_renderer( array $args = array() ): string {
368368
* order — pointer-events:none already blocks the mouse, this aligns keyboard
369369
* behavior with it.
370370
*
371-
* @param array $atts Link attributes.
372-
* @param WP_Post $item Menu item data object.
373-
* @param stdClass $args An object of wp_nav_menu() arguments.
374-
* @param integer $depth Depth of menu item.
371+
* @param array $atts Link attributes.
372+
* @param WP_Post|null $item Menu item data object.
373+
* @param stdClass|null $args An object of wp_nav_menu() arguments.
374+
* @param integer $depth Depth of menu item.
375375
*
376376
* @return array
377377
*/

‎themes/osi/style.css‎

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎themes/osi/style.css.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)