Skip to content

Commit

Permalink
Merge pull request #486 from devgeniem/TMS-940
Browse files Browse the repository at this point in the history
TMS-940: mobile language-nav accessibility fix
  • Loading branch information
eebbi authored Dec 4, 2023
2 parents 9f06e6b + 4a50ede commit ee0095d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Search-page form accessibility fixes
- Header search accessibility fixes
- Added focus on input when opening header search
- TMS-940: Hide current language on mobile header if only 2 languages in use

## [1.54.2] - 2023-11-22

Expand Down
16 changes: 13 additions & 3 deletions models/shared/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,18 @@ public function language_nav() : ?array {
'hide_empty' => 0,
];

$languages = pll_the_languages( $args );
$languages = \pll_the_languages( $args );
$lang_data = [ 'all' => $languages ];

// If there are two languages, show only one in mobile view
if ( count( $languages ) === 2 ) {
$args['hide_current'] = 1;
$without_current = \pll_the_languages( $args );
$lang_data_mobile = [
'all' => $without_current,
];
}

foreach ( $languages as $lang ) {
if ( ! empty( $lang['current_lang'] ) ) {
$lang_data['current'] = $lang;
Expand All @@ -99,10 +108,11 @@ public function language_nav() : ?array {
}

return [
'partial' => 'dropdown' === $lang_nav_display
'partial' => 'dropdown' === $lang_nav_display
? 'ui/menu/language-nav-dropdown'
: 'ui/menu/language-nav',
'links' => $lang_data,
'links' => $lang_data,
'links_without_current' => $lang_data_mobile,
];
}

Expand Down
14 changes: 10 additions & 4 deletions partials/shared/header-inner.dust
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
{/Header.lang_nav_horizontal}

{?Header.lang_nav_horizontal}
<div class="is-hidden-desktop">
<div class="is-hidden-desktop">
{?Header.language_nav.links_without_current}
{>"ui/menu/language-nav" links=Header.language_nav.links_without_current /}
{:else}
{>"ui/menu/language-nav-dropdown" links=Header.language_nav.links /}
{/Header.language_nav.links_without_current}
</div>
{/Header.lang_nav_horizontal}
{>"ui/menu/language-nav-dropdown" links=Header.language_nav.links /}
{?Header.lang_nav_horizontal}
</div>

{^Header.lang_nav_horizontal}
{>"ui/menu/language-nav-dropdown" links=Header.language_nav.links /}
{/Header.lang_nav_horizontal}

{^Header.hide_search}
Expand Down
2 changes: 1 addition & 1 deletion partials/ui/menu/menu-item-simple.dust
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="{url}" class="navbar-item {#classes}{.}{@sep} {/sep}{/classes}" {?classes.is_current}aria-page="current"{/classes.is_current}>
<a href="{url}" class="navbar-item {#classes}{.}{@sep} {/sep}{/classes}" {?classes.is_current}aria-current="page"{/classes.is_current}>
{title|s}

{?icon}
Expand Down

0 comments on commit ee0095d

Please sign in to comment.