Skip to content

Commit 4d6e2c2

Browse files
authored
Merge pull request #5624 from uswds/al-safari-bug-fix-regression
USWDS - Header: Use $theme-header-min-width for safari fix calc
2 parents 2085542 + 4ffcfa0 commit 4d6e2c2

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

packages/usa-nav/src/styles/_usa-nav.scss

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use "sass:map";
12
@use "uswds-core" as *;
23

34
// Navigation helpers
@@ -476,19 +477,26 @@ $expand-less-icon: map-merge(
476477
}
477478

478479
// Safari-only fix that forces a vertical scrollbar when mobile menu is open.
479-
// Only needed in the 15px immediately preceding $theme-header-max-width.
480+
// Only needed in the 15px immediately preceding $theme-header-min-width.
480481
//
481482
// Note: 15px is the current width of the Safari scrollbar.
482-
// More details in https://github.com/uswds/uswds/pull/5443
483-
$safari-header-bug-min-width: calc(
484-
units($theme-header-max-width) - px-to-rem(15px)
485-
);
486-
487-
@media (min-width: $safari-header-bug-min-width) {
488-
.usa-js-mobile-nav--active.is-safari {
489-
overflow-y: scroll;
490-
position: fixed;
491-
// --scrolltop set with JS with zero as fallback.
492-
top: var(--scrolltop, 0);
483+
// Note: This fix only applies when $theme-header-min-width is defined with a system breakpoint
484+
// because the header visually breaks with other values.
485+
// This bypass prevents compilation errors with values like "none" or 1px.
486+
487+
$our-breakpoints: map-deep-get($system-properties, breakpoints, standard);
488+
489+
@if map-has-key($our-breakpoints, $theme-header-min-width) {
490+
$safari-header-bug-min-width: calc(
491+
units($theme-header-min-width) - px-to-rem(15px)
492+
);
493+
494+
@media (min-width: $safari-header-bug-min-width) {
495+
.usa-js-mobile-nav--active.is-safari {
496+
overflow-y: scroll;
497+
position: fixed;
498+
// --scrolltop set with JS with zero as fallback.
499+
top: var(--scrolltop, 0);
500+
}
493501
}
494502
}

0 commit comments

Comments
 (0)