Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: use proper heading props for dialog and sheet components (#2400)

Juan Di Torocf7711eb7f92
diff --git a/packages/sdk-components-react-radix/package.json b/packages/sdk-components-react-radix/package.json
index 229fc04a0a..7d5711f692 100644
--- a/packages/sdk-components-react-radix/package.json
+++ b/packages/sdk-components-react-radix/package.json
@@ -41,7 +41,7 @@
"scripts": {
"dev": "rm -rf lib && esbuild 'src/**/*.ts' 'src/**/*.tsx' --outdir=lib --watch",
"build": "rm -rf lib && esbuild src/components.ts src/metas.ts src/props.ts src/hooks.ts --outdir=lib --bundle --format=esm --packages=external",
- "build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/accordion.tsx !./src/*.stories.tsx !./src/*.ws.tsx' -e asChild -e modal -e defaultValue -e defaultOpen -e defaultChecked && prettier --write \"**/*.props.ts\"",
+ "build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.ws.tsx' -e asChild -e modal -e defaultValue -e defaultOpen -e defaultChecked && prettier --write \"**/*.props.ts\"",
"build:tailwind": "tsx scripts/generate-tailwind-theme.ts && prettier --write src/theme/__generated__",
"build:stories": "webstudio-sdk generate-stories && prettier --write \"src/__generated__/*.stories.tsx\"",
"dts": "tsc --project tsconfig.dts.json",
diff --git a/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts b/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts
index 0cd9554da6..65f7fc78c0 100644
--- a/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts
+++ b/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts
@@ -2327,6 +2327,13 @@ export const propsDialogTitle: Record<string, PropMeta> = {
description:
"Overrides the browser's default tab order and follows the one specified instead.",
},
+ tag: {
+ required: false,
+ control: "select",
+ type: "string",
+ defaultValue: "h1",
+ options: ["h2", "h3", "h1", "h4", "h5", "h6"],
+ },
title: {
required: false,
control: "text",
diff --git a/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts b/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts
index 75aea9c87d..58b0247b49 100644
--- a/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts
+++ b/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts
@@ -1760,6 +1760,13 @@ export const propsSheetTitle: Record<string, PropMeta> = {
description:
"Overrides the browser's default tab order and follows the one specified instead.",
},
+ tag: {
+ required: false,
+ control: "select",
+ type: "string",
+ defaultValue: "nav",
+ options: ["h2", "h3", "h1", "h4", "h5", "h6"],
+ },
title: {
required: false,
control: "text",
diff --git a/packages/sdk-components-react-radix/src/dialog.tsx b/packages/sdk-components-react-radix/src/dialog.tsx
index 0abdc2be7a..0ec90e8369 100644
--- a/packages/sdk-components-react-radix/src/dialog.tsx
+++ b/packages/sdk-components-react-radix/src/dialog.tsx
@@ -6,6 +6,7 @@ import {
type ReactNode,
forwardRef,
Children,
+ type ComponentProps,
} from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk";
@@ -50,7 +51,20 @@ export const DialogOverlay = forwardRef<
export const DialogContent = DialogPrimitive.Content;
export const DialogClose = DialogPrimitive.Close;
-export const DialogTitle = DialogPrimitive.Title;
+
+type Tag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
+const defaultTag = "h1";
+export const DialogTitle = forwardRef<
+ HTMLHeadingElement,
+ ComponentProps<typeof DialogPrimitive.DialogTitle> & { tag?: Tag }
+>(({ tag: Tag = defaultTag, children, ...props }, ref) => (
+ <DialogPrimitive.DialogTitle asChild>
+ <Tag ref={ref} {...props}>
+ {children ?? "Heading title you can edit"}
+ </Tag>
+ </DialogPrimitive.DialogTitle>
+));
+
export const DialogDescription = DialogPrimitive.Description;
/* BUILDER HOOKS */