Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent sticky header from hiding when localization selector is open #3188

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/component-localization-form.css
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ noscript .localization-selector.link {
height: 100%;
background-color: rgba(var(--color-foreground), 0.5);
z-index: 3;
animation: animateLocalization var(--duration-default) ease;
}

.disclosure__list-wrapper.country-selector {
Expand Down
5 changes: 5 additions & 0 deletions assets/localization-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if (!customElements.get('localization-form')) {
constructor() {
super();
this.mql = window.matchMedia('(min-width: 750px)');
this.header = document.querySelector('.header-wrapper');
this.elements = {
input: this.querySelector('input[name="locale_code"], input[name="country_code"]'),
button: this.querySelector('button.localization-form__select'),
Expand Down Expand Up @@ -47,6 +48,7 @@ if (!customElements.get('localization-form')) {
}
document.body.classList.remove('overflow-hidden-mobile');
document.querySelector('.menu-drawer').classList.remove('country-selector-open');
this.header.preventHide = false;
}

onContainerKeyDown(event) {
Expand Down Expand Up @@ -120,6 +122,9 @@ if (!customElements.get('localization-form')) {
if (this.elements.search && this.mql.matches) {
this.elements.search.focus();
}
if (this.hasAttribute('data-prevent-hide')) {
this.header.preventHide = true;
}
document.querySelector('.menu-drawer').classList.add('country-selector-open');
}

Expand Down
4 changes: 2 additions & 2 deletions sections/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
{%- endform -%}
</noscript>

<localization-form class="small-hide medium-hide no-js-hidden">
<localization-form class="small-hide medium-hide no-js-hidden" data-prevent-hide>
{%- form 'localization', id: 'HeaderCountryForm', class: 'localization-form' -%}
<div>
<h2 class="visually-hidden" id="HeaderCountryLabel">{{ 'localization.country_label' | t }}</h2>
Expand Down Expand Up @@ -283,7 +283,7 @@
{%- endform -%}
</noscript>

<localization-form class="small-hide medium-hide no-js-hidden">
<localization-form class="small-hide medium-hide no-js-hidden" data-prevent-hide>
{%- form 'localization', id: 'HeaderLanguageForm', class: 'localization-form' -%}
<div>
<h2 class="visually-hidden" id="HeaderLanguageLabel">{{ 'localization.language_label' | t }}</h2>
Expand Down Expand Up @@ -495,7 +495,7 @@
</script>
{%- endif -%}

{% schema %}

Check notice on line 498 in sections/header.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/header.liquid#L498

[SchemaJsonFormat] JSON formatting could be improved
{
"name": "t:sections.header.name",
"class": "section-header",
Expand Down
Loading