Skip to content

Open source CapCut alternative.

TypeScript

fix(site): keep dialogs from scrolling sideways

David Lea8ec13ae9346
diff --git a/site/src/components/ui/dialog.test.tsx b/site/src/components/ui/dialog.test.tsx
index 74c68e0a..e1454951 100644
--- a/site/src/components/ui/dialog.test.tsx
+++ b/site/src/components/ui/dialog.test.tsx
@@ -1,5 +1,6 @@
import { expect, test } from "bun:test"
import * as React from "react"
+import { renderToStaticMarkup } from "react-dom/server"
import {
DialogBody,
DialogFooter,
@@ -41,3 +42,13 @@ test("the scrolling part leaves room for a focused field's ring", () => {
expect(body.type).toBe(DialogBody)
expect(body.props.className).not.toContain("px-0")
})
+
+// A control's hit area may reach past the padding, as a switch's does at the
+// row's end. The scrolling part scrolls up and down only.
+test("the scrolling part never scrolls sideways", () => {
+ const out = React.Children.toArray(
+ withScrollingMiddle([<DialogHeader key="h" />, <input key="i" />], CHROME)
+ ) as Shaped[]
+ const html = renderToStaticMarkup(out[1])
+ expect(html).toContain("overflow-x-hidden")
+})
diff --git a/site/src/components/ui/dialog.tsx b/site/src/components/ui/dialog.tsx
index 45c2b0a7..1c4f77ae 100644
--- a/site/src/components/ui/dialog.tsx
+++ b/site/src/components/ui/dialog.tsx
@@ -187,7 +187,7 @@ function DialogBody({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-body"
- className={cn("-mx-4 -my-1 min-h-0 flex-1 overflow-y-auto px-4 py-1", className)}
+ className={cn("-mx-4 -my-1 min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 py-1", className)}
{...props}
/>
)