From: Mark Otto Date: Thu, 4 Jun 2026 23:19:56 +0000 (-0700) Subject: docs: fix menu clipping in resizable examples + configurable dev port (#42470) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d5439179311bab70ac07d135755096ffe19cb37;p=thirdparty%2Fbootstrap.git docs: fix menu clipping in resizable examples + configurable dev port (#42470) * docs: prevent menus from being clipped in resizable examples The resizable container needs overflow: hidden for the CSS resize handle to work, which clips menus/dropdowns when they open. Render them with a fixed positioning strategy in the live preview only so they can spill outside the container, leaving the displayed markup untouched. * docs: make the Astro dev server port configurable via PORT Default to 9001 but allow PORT to override the dev/preview server port so multiple worktrees can run side by side without colliding. --- diff --git a/package.json b/package.json index b35343ccbb..00e2bf414a 100644 --- a/package.json +++ b/package.json @@ -112,9 +112,9 @@ "watch-js-main": "nodemon --watch js/src/ --ext js --exec \"npm-run-all js-lint js-compile\"", "watch-js-docs": "nodemon --watch site/src/assets/ --ext js --exec \"npm run js-lint\"", "astro-clean": "rm -rf site/.astro site/node_modules/.astro", - "astro-dev": "astro dev --root site --port 9001", + "astro-dev": "astro dev --root site", "astro-build": "astro build --root site && rm -rf _site && cp -r site/dist _site && pagefind --site _site", - "astro-preview": "astro preview --root site --port 9001", + "astro-preview": "astro preview --root site", "spellcheck": "cspell --config .cspell.json \"**/*.{md,mdx}\"" }, "peerDependencies": { diff --git a/site/astro.config.ts b/site/astro.config.ts index a8cdc6dbb6..b9f31c05c7 100644 --- a/site/astro.config.ts +++ b/site/astro.config.ts @@ -17,9 +17,13 @@ const bootstrapBundlePath = fileURLToPath(new URL('../dist/js/bootstrap.bundle.j const isDev = process.env.NODE_ENV === 'development' +// Allow the dev/preview server port to be overridden via `PORT` (falling back to +// 9001) so multiple worktrees can run side by side without colliding. +const port = Number.parseInt(process.env.PORT ?? '', 10) || 9001 + const site = isDev ? // In development mode, use the local dev server. - 'http://localhost:9001' + `http://localhost:${port}` : process.env.DEPLOY_PRIME_URL !== undefined ? // If deploying on Netlify, use the `DEPLOY_PRIME_URL` environment variable. process.env.DEPLOY_PRIME_URL @@ -66,6 +70,9 @@ export default defineConfig({ devToolbar: { enabled: false }, + server: { + port + }, site, vite: { plugins: [stackblitzPlugin()], diff --git a/site/src/components/shortcodes/ResizableExample.astro b/site/src/components/shortcodes/ResizableExample.astro index 0dffc70530..525ebed8d7 100644 --- a/site/src/components/shortcodes/ResizableExample.astro +++ b/site/src/components/shortcodes/ResizableExample.astro @@ -47,6 +47,15 @@ const containerClass = className || classFromClass let markup = Array.isArray(code) ? code.join('\n') : code markup = replacePlaceholdersInHtml(markup) +// The resizable container needs `overflow: hidden` for the CSS `resize` handle +// to work, which clips popovers like menus/dropdowns when they open. Render them +// with a fixed positioning strategy in the live preview only so they can spill +// outside the container. The displayed markup below is left untouched. +const previewMarkup = markup.replace( + /data-bs-toggle="(menu|dropdown)"(?![^>]*\bdata-bs-strategy=)/g, + 'data-bs-toggle="$1" data-bs-strategy="fixed"' +) + const simplifiedMarkup = markup.replace( //g, (match, classes) => `...` @@ -59,7 +68,7 @@ const simplifiedMarkup = markup.replace( class:list={['bd-resizable-container', containerClass]} style={`width: ${initialWidth}; min-width: ${minWidth};`} > - + {showMarkup && }