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

fix(site-header): fix mobile display of language popover - FRONT-3839 #2734

Merged
merged 1 commit into from
Jan 25, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ $_active-item-background: null !default;
}
}

.ecl-site-header__language-container--push-left::before {
left: var(--ecl-language-arrow-position);
}

.ecl-site-header__language-container--push-right::before {
.ecl-site-header__language-container--push-right::before,
.ecl-site-header__language-container--full::before {
left: auto;
right: var(--ecl-language-arrow-position);
}
Expand Down Expand Up @@ -84,10 +81,6 @@ $_active-item-background: null !default;
padding: 0 map.get(theme.$spacing, 's') map.get(theme.$spacing, 's');
}

.ecl-site-header__language-category {
width: max-content;
}

.ecl-site-header__language-category:nth-child(2) {
border-top: 1px solid $_separator-color;
margin-top: map.get(theme.$spacing, 'm');
Expand Down Expand Up @@ -156,11 +149,6 @@ $_active-item-background: null !default;
}

// Horizontal position
.ecl-site-header__language-container--push-left {
left: 0;
transform: none;
}

.ecl-site-header__language-container--push-right {
left: auto;
right: 0;
Expand Down
24 changes: 20 additions & 4 deletions src/implementations/vanilla/components/site-header/site-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ export class SiteHeader {
)}-col`
);
}
} else {
this.languageListEu.parentNode.classList.remove(
'ecl-site-header__language-content--stack'
);
}

// Check available space
Expand All @@ -276,6 +272,7 @@ export class SiteHeader {
popoverRect = this.languageListOverlay.getBoundingClientRect();
const screenWidth = window.innerWidth;

// Popover too large
if (popoverRect.right > screenWidth) {
const linkRect = this.languageLink.getBoundingClientRect();

Expand All @@ -297,6 +294,25 @@ export class SiteHeader {
`calc(${arrowPosition}px - ${arrowSize})`
);
}

// Mobile popover (full width)
if (popoverRect.left === 0) {
const linkRect = this.languageLink.getBoundingClientRect();

// Push the popover to the right
this.languageListOverlay.classList.add(
'ecl-site-header__language-container--full'
);

// Adapt arrow position
const arrowPosition =
popoverRect.right - linkRect.right + linkRect.width / 2;
const arrowSize = '0.5rem';
this.languageListOverlay.style.setProperty(
'--ecl-language-arrow-position',
`calc(${arrowPosition}px - ${arrowSize})`
);
}
}

/**
Expand Down