Skip to content

Commit 01d20a3

Browse files
Updates
Signed-off-by: Kristin Brown <kristin.brown@solo.io>
1 parent 6acf1f4 commit 01d20a3

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

layouts/partials/copy-markdown.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@
136136
.dark .copy-md-dropdown button:hover{background:rgba(255,255,255,0.05);color:#f9fafb;}
137137
.copy-md-dropdown-sep{height:1px;background:#e5e7eb;margin:0.25rem 0;}
138138
.dark .copy-md-dropdown-sep{background:#374151;}
139-
.copy-md-dialog{padding:0;border:none;border-radius:0.5rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);max-width:min(900px,90vw);width:100%;max-height:85vh;flex-direction:column;background:#fff;}
139+
/* Specify width directly rather than width:100%+max-width. Safari's
140+
modal <dialog> resolves width:100% against an intrinsic-content
141+
containing block, so the dialog shrinks to fit its <pre> child
142+
rather than the viewport. Chrome/Firefox treat 100% as viewport-
143+
relative. Setting width explicitly produces consistent sizing
144+
across all three engines. */
145+
.copy-md-dialog{padding:0;border:none;border-radius:0.5rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);width:min(900px,90vw);max-height:85vh;flex-direction:column;background:#fff;}
140146
.copy-md-dialog[open]{display:flex;}
141147
.dark .copy-md-dialog{background:#1f2937;color:#e5e7eb;}
142148
.copy-md-dialog::backdrop{background:rgba(0,0,0,0.5);}

tests/cross-browser.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,42 @@ test.describe("interactive components work cross-browser", () => {
153153
expect(textContent).toContain("MARKER_MERMAID_REQUEST");
154154
});
155155

156+
test("'View as Markdown' dialog opens at consistent size across engines", async ({
157+
page,
158+
}) => {
159+
await page.goto(EVERYTHING);
160+
161+
// Open the copy-md dropdown by clicking its caret toggle, then click
162+
// the "View as Markdown" menu item. The dialog opens as a modal
163+
// <dialog>, sized by CSS.
164+
const toggle = page.locator(".copy-md-toggle").first();
165+
if (await toggle.count() === 0) {
166+
test.skip(true, "no copy-md dropdown on this page (consumer didn't wire it)");
167+
}
168+
await toggle.click();
169+
const viewBtn = page.locator('button[data-action="view"]').first();
170+
await viewBtn.click();
171+
172+
const dialog = page.locator(".copy-md-dialog").first();
173+
await expect(dialog).toBeVisible({ timeout: 5_000 });
174+
const box = await dialog.boundingBox();
175+
expect(box, "dialog has no bounding box").not.toBeNull();
176+
177+
// Regression guard for a Safari-specific bug where the modal <dialog>
178+
// resolved width:100% against its intrinsic-content containing block
179+
// (collapsing the dialog to <pre> width, ~300px) instead of the
180+
// viewport (Chrome/Firefox behavior). CSS now sets width directly.
181+
//
182+
// At the cross-browser desktop viewport (1280px), the dialog should
183+
// render at min(900px, 90vw) = 900px. Threshold 600px is generous
184+
// enough to absorb sub-pixel rounding while still catching the
185+
// collapsed-to-content failure mode (which produces widths < 400px).
186+
expect(
187+
box!.width,
188+
`dialog width ${box!.width}px is too small — modal <dialog> likely collapsed to content`,
189+
).toBeGreaterThan(600);
190+
});
191+
156192
test("theme toggle adds html.dark class", async ({ page }) => {
157193
await page.goto(EVERYTHING);
158194
// Force-toggle via the same class the Hextra theme button sets, so this

0 commit comments

Comments
 (0)