fix 漢堡主項點擊展開

This commit is contained in:
2026-05-16 20:50:36 +08:00
parent da4aba8eb7
commit 3b6c8db2e0
2 changed files with 76 additions and 24 deletions
+16
View File
@@ -345,6 +345,7 @@
const subgroupHead = event.target.closest(".portal-nav__subgroup-head");
if (subgroupHead) {
event.preventDefault();
event.stopPropagation();
const subgroup = subgroupHead.closest(".portal-nav__subgroup");
if (subgroup) subgroup.classList.toggle("open");
return;
@@ -352,6 +353,17 @@
const link = event.target.closest("a[href]");
if (!link || link.classList.contains("logo")) return;
const topItem = link.closest(".portal-nav > ul > li");
const isTopTrigger =
topItem &&
link === topItem.querySelector(":scope > a") &&
topItem.querySelector(":scope > .portal-submenu");
if (isTopTrigger) {
return;
}
if (link.getAttribute("data-coming-soon") === "true") return;
const href = link.getAttribute("href");
if (href && href !== "#") setPortalNavMenuOpen(nav, false);
@@ -437,7 +449,11 @@
if (!isPortalNavDesktop()) {
event.preventDefault();
event.stopPropagation();
if (!isSoon && !item.classList.contains("coming-soon")) {
items.forEach((other) => {
if (other !== item) other.classList.remove("open");
});
item.classList.toggle("open");
}
return;