fix: 모바일에서 헤더 앱 드롭다운이 안 열리던 문제
사용자 신고: "모바일에서 앱모음 탭이 풀다운 되지 않던데?"
드롭다운은 원래도 열리고 있었다. 보이지 않게 잘려 있었을 뿐이다.
모바일(max-width:1024px)에서 앱 버튼 스트립은 가로 스크롤 컨테이너가 된다.
header .mode-toggle { overflow-x: auto; mask-image: linear-gradient(...); }
여기서 두 가지가 다 자른다. overflow-x를 visible이 아닌 값으로 두면 명세상
overflow-y도 auto가 되고, mask는 자손까지 함께 잘라낸다. 메뉴는
top:calc(100% + 4px)로 스트립 박스 바깥에 놓이므로 통째로 잘려나갔다.
z-index:2000은 무용지물 — 조상의 클리핑은 z-index로 못 넘는다.
처음엔 position:fixed만 주면 될 줄 알았으나 틀렸다. 브라우저에서 재보니
fixed를 줘도 여전히 안 보였다(메뉴 중심점에 body가 그려짐). fixed는 overflow
클리핑은 벗어나지만 mask는 못 벗어난다. 세 방법을 나란히 측정한 결과:
A. fixed만 -> 안 보임
B. fixed + mask 제거 -> 보임
C. 메뉴를 body로 이동 -> 보임 (mask 유지)
오른쪽 페이드 힌트를 살리려고 C를 택했다. 열릴 때 body로 옮기고 dd-floating
클래스로 fixed 좌표를 주며, 닫힐 때 원래 .mode-dropdown 아래로 되돌린다.
되돌리지 않으면 다음 열기에서 previousElementSibling이 버튼을 못 찾는다.
데스크탑은 그대로 — 거기선 스트립에 스크롤도 mask도 없어서 기존 absolute
배치가 이미 정상이다.
검증(실제 스타일시트와 실제 함수를 그대로 불러온 페이지, 브레이크포인트만 이동):
열기 가시성, 다른 드롭다운 전환 시 이전 것 DOM 복원, 바깥 클릭 후 복원,
재열기 시 버튼 재탐색, 우측 끝 버튼의 화면 밖 이탈 방지 — 전부 통과.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b5c93df8e
commit
0a477f14cd
2 files changed
+46
-2
No files matched your search
@@ -139,6 +139,12 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
.mode-dropdown-menu.open { display: block; }
|
||||
/* Mobile only, applied by positionModeDropdown() after it moves the menu to <body>. The menu
|
||||
cannot stay inside the app strip there: the strip scrolls horizontally, and its mask-image
|
||||
clips descendants — including position:fixed ones, which do escape overflow but not a mask.
|
||||
Measured 2026-08-14: fixed-inside-the-strip was still invisible; only leaving the strip
|
||||
worked. Being viewport-positioned, it needs coordinates from JS. */
|
||||
.mode-dropdown-menu.dd-floating { position: fixed; z-index: 3000; }
|
||||
.mode-dropdown-menu button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
|
||||
+40
-2
@@ -18,18 +18,56 @@ function toggleModeDropdown(e, id) {
|
||||
var menu = document.getElementById(id.replace('mode-dropdown-', 'mode-dropdown-menu-'));
|
||||
if (!menu) return;
|
||||
var opening = !menu.classList.contains('open');
|
||||
document.querySelectorAll('.mode-dropdown-menu.open').forEach(function(m) { m.classList.remove('open'); });
|
||||
document.querySelectorAll('.mode-dropdown-menu.open').forEach(closeMenu);
|
||||
if (opening) {
|
||||
menu.classList.add('open');
|
||||
positionModeDropdown(menu);
|
||||
setTimeout(function() {
|
||||
document.addEventListener('click', function closeModeDropdown() {
|
||||
menu.classList.remove('open');
|
||||
closeMenu(menu);
|
||||
document.removeEventListener('click', closeModeDropdown);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function closeMenu(m) {
|
||||
m.classList.remove('open');
|
||||
m.classList.remove('dd-floating');
|
||||
m.style.left = '';
|
||||
m.style.top = '';
|
||||
// Put it back next to its button, so previousElementSibling still finds the button next time.
|
||||
if (m._ddHome) { m._ddHome.appendChild(m); m._ddHome = null; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an open dropdown on mobile by moving it out to <body>.
|
||||
*
|
||||
* On mobile the app strip becomes a horizontally scrolling container with a right-edge fade
|
||||
* (mask-image). Both of those clip descendants, so a menu hanging below the strip was clipped out
|
||||
* of existence — the dropdown opened and simply could not be seen, and z-index cannot climb out of
|
||||
* an ancestor's clip.
|
||||
*
|
||||
* position:fixed alone does NOT fix it: fixed escapes overflow clipping but not a mask. Measured
|
||||
* 2026-08-14 with the menu fixed and still inside the strip — invisible, with <body> painted at
|
||||
* its centre. Leaving the strip entirely is what works, so the menu is reparented to <body> while
|
||||
* open and returned to its dropdown afterwards. Desktop is untouched: there the strip has no
|
||||
* scroller and no mask, and plain CSS-absolute placement already works.
|
||||
*/
|
||||
function positionModeDropdown(menu) {
|
||||
if (window.innerWidth > 1024) return;
|
||||
var btn = menu.previousElementSibling;
|
||||
if (!btn) return;
|
||||
var r = btn.getBoundingClientRect();
|
||||
menu._ddHome = menu.parentElement;
|
||||
document.body.appendChild(menu);
|
||||
menu.classList.add('dd-floating');
|
||||
var width = menu.offsetWidth || 130; // measured after the move, once it is laid out unclipped
|
||||
// Buttons near the right edge would otherwise push the menu off-screen.
|
||||
menu.style.left = Math.round(Math.max(4, Math.min(r.left, window.innerWidth - width - 4))) + 'px';
|
||||
menu.style.top = Math.round(r.bottom + 4) + 'px';
|
||||
}
|
||||
|
||||
function getAuthToken() { try { return sessionStorage.getItem(TOKEN_KEY) || ''; } catch { return ''; } }
|
||||
function setAuthToken(t) { try { t ? sessionStorage.setItem(TOKEN_KEY, t) : sessionStorage.removeItem(TOKEN_KEY); t ? localStorage.setItem(TOKEN_KEY, t) : localStorage.removeItem(TOKEN_KEY); } catch {} }
|
||||
function authHeaders(extra) { const t = getAuthToken(); const h = { ...(extra||{}) }; if (t) h['Authorization'] = 'Bearer ' + t; return h; }
|
||||
|
||||
Reference in new issue
Block a user