···11+export function update() {
22+ const nav = document.getElementById("diffuse-nav");
33+ const btn = document.getElementById("nav-overflow-btn");
44+ const menu = document.getElementById("nav-overflow-menu");
55+66+ if (!nav || !btn || !menu) return;
77+88+ const items = /** @type {HTMLElement[]} */ ([...nav.children]);
99+1010+ // Reset: show all items, hide button
1111+ for (const item of items) item.style.display = "";
1212+ btn.style.display = "none";
1313+1414+ // No overflow — nothing to do
1515+ if (nav.scrollWidth <= nav.clientWidth) return;
1616+1717+ // Show button (nav shrinks to accommodate it via flex)
1818+ btn.style.display = "";
1919+2020+ // Hide items from right until nav content fits
2121+ const hidden = [];
2222+ for (let i = items.length - 1; i >= 0; i--) {
2323+ if (nav.scrollWidth <= nav.clientWidth) break;
2424+ items[i].style.display = "none";
2525+ hidden.unshift(items[i]);
2626+ }
2727+2828+ // Populate dropdown with clones (stripped of button styling)
2929+ menu.innerHTML = "";
3030+ for (const el of hidden) {
3131+ if (el.classList.contains("divider")) continue;
3232+3333+ const clone = /** @type {HTMLElement} */ (el.cloneNode(true));
3434+ clone.style.display = "";
3535+ clone.classList.remove(
3636+ "button",
3737+ "button--transparent",
3838+ "button--border",
3939+ "button--bg-twist-2",
4040+ );
4141+4242+ menu.appendChild(clone);
4343+ }
4444+}
4545+4646+export function watchResize() {
4747+ const nav = document.getElementById("diffuse-nav");
4848+ if (nav) new ResizeObserver(update).observe(nav);
4949+}
+4
src/common/pages/ppr.js
···22import * as Dashboard from "./dashboard.js";
33import * as Grid from "./grid.js";
44import * as Guide from "./guide.js";
55+import * as Nav from "./nav.js";
5667/** Base pathname of the app (e.g. "/" at root, "/diffuse/" in a subdirectory). */
78const BASE_PATHNAME = new URL(document.baseURI).pathname;
···2526 */
2627async function initJsBasedOnPage(url) {
2728 const path = relativePathname(url.pathname);
2929+3030+ Nav.update();
3131+ Nav.watchResize();
28322933 Grid.insertToggleButtons();
3034 await Grid.monitorToggleButtonStates();