Skip to content

Commit

Permalink
Prevent scrollbar overflow in footer disclosures (#1293)
Browse files Browse the repository at this point in the history
* Prevent scrollbar overflow in footer disclosures

* Add scroll padding
  • Loading branch information
kmeleta authored Feb 10, 2022
1 parent 2c7b352 commit ad989e6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
27 changes: 16 additions & 11 deletions assets/disclosure.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,11 @@
background-color: transparent;
}

.disclosure__list {
.disclosure__list-wrapper {
border-width: var(--popup-border-width);
border-style: solid;
border-color: rgba(var(--color-foreground), var(--popup-border-opacity));
font-size: 1.4rem;
margin-top: -0.5rem;
min-height: 8.2rem;
max-height: 19rem;
max-width: 22rem;
min-width: 12rem;
width: max-content;
overflow-y: auto;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
overflow: hidden;
position: absolute;
bottom: 100%;
transform: translateY(-1rem);
Expand All @@ -35,6 +26,20 @@
box-shadow: var(--popup-shadow-horizontal-offset) var(--popup-shadow-vertical-offset) var(--popup-shadow-blur-radius) rgba(var(--color-shadow), var(--popup-shadow-opacity));
}

.disclosure__list {
position: relative;
overflow-y: auto;
font-size: 1.4rem;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
scroll-padding: 0.5rem 0;
min-height: 8.2rem;
max-height: 19rem;
max-width: 22rem;
min-width: 12rem;
width: max-content;
}

.disclosure__item {
position: relative;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/section-footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ noscript .localization-selector.link {
color: #000000;
}

.localization-selector + .disclosure__list {
.localization-selector + .disclosure__list-wrapper {
margin-left: 1rem;
opacity: 1;
animation: animateLocalization var(--duration-default) ease;
Expand Down
42 changes: 23 additions & 19 deletions sections/footer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,17 @@
{{ localization.country.name }} ({{ localization.country.currency.iso_code }} {{ localization.country.currency.symbol }})
{% render 'icon-caret' %}
</button>
<ul id="FooterCountryList" role="list" class="disclosure__list list-unstyled" hidden>
{%- for country in localization.available_countries -%}
<li class="disclosure__item" tabindex="-1">
<a class="link link--text disclosure__link caption-large{% if country.iso_code == localization.country.iso_code %} disclosure__link--active{% endif %} focus-inset" href="#"{% if country.iso_code == localization.country.iso_code %} aria-current="true"{% endif %} data-value="{{ country.iso_code }}">
{{ country.name }} <span class="localization-form__currency">({{ country.currency.iso_code }} {{ country.currency.symbol }})</span>
</a>
</li>
{%- endfor -%}
</ul>
<div class="disclosure__list-wrapper" hidden>
<ul id="FooterCountryList" role="list" class="disclosure__list list-unstyled">
{%- for country in localization.available_countries -%}
<li class="disclosure__item" tabindex="-1">
<a class="link link--text disclosure__link caption-large{% if country.iso_code == localization.country.iso_code %} disclosure__link--active{% endif %} focus-inset" href="#"{% if country.iso_code == localization.country.iso_code %} aria-current="true"{% endif %} data-value="{{ country.iso_code }}">
{{ country.name }} <span class="localization-form__currency">({{ country.currency.iso_code }} {{ country.currency.symbol }})</span>
</a>
</li>
{%- endfor -%}
</ul>
</div>
</div>
<input type="hidden" name="country_code" value="{{ localization.country.iso_code }}">
</div>
Expand Down Expand Up @@ -296,15 +298,17 @@
{{ localization.language.endonym_name | capitalize }}
{% render 'icon-caret' %}
</button>
<ul id="FooterLanguageList" role="list" class="disclosure__list list-unstyled" hidden>
{%- for language in localization.available_languages -%}
<li class="disclosure__item" tabindex="-1">
<a class="link link--text disclosure__link caption-large{% if language.iso_code == localization.language.iso_code %} disclosure__link--active{% endif %} focus-inset" href="#" hreflang="{{ language.iso_code }}" lang="{{ language.iso_code }}"{% if language.iso_code == localization.language.iso_code %} aria-current="true"{% endif %} data-value="{{ language.iso_code }}">
{{ language.endonym_name | capitalize }}
</a>
</li>
{%- endfor -%}
</ul>
<div class="disclosure__list-wrapper" hidden>
<ul id="FooterLanguageList" role="list" class="disclosure__list list-unstyled">
{%- for language in localization.available_languages -%}
<li class="disclosure__item" tabindex="-1">
<a class="link link--text disclosure__link caption-large{% if language.iso_code == localization.language.iso_code %} disclosure__link--active{% endif %} focus-inset" href="#" hreflang="{{ language.iso_code }}" lang="{{ language.iso_code }}"{% if language.iso_code == localization.language.iso_code %} aria-current="true"{% endif %} data-value="{{ language.iso_code }}">
{{ language.endonym_name | capitalize }}
</a>
</li>
{%- endfor -%}
</ul>
</div>
</div>
<input type="hidden" name="locale_code" value="{{ localization.language.iso_code }}">
</div>
Expand Down Expand Up @@ -341,7 +345,7 @@
this.elements = {
input: this.querySelector('input[name="locale_code"], input[name="country_code"]'),
button: this.querySelector('button'),
panel: this.querySelector('ul'),
panel: this.querySelector('.disclosure__list-wrapper'),
};
this.elements.button.addEventListener('click', this.openSelector.bind(this));
this.elements.button.addEventListener('focusout', this.closeSelector.bind(this));
Expand Down

0 comments on commit ad989e6

Please sign in to comment.