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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Accordion SEO (#5804)
Oleg Isonenf099e60b51f0
diff --git a/apps/builder/app/canvas/inflator.test.ts b/apps/builder/app/canvas/inflator.test.tsindex 24c9c8a164..50a27d0022 100644--- a/apps/builder/app/canvas/inflator.test.ts+++ b/apps/builder/app/canvas/inflator.test.ts@@ -264,6 +264,20 @@ describe("getInflationState", () => {expect(call({ offsetHeight: 0 })).toBe("h");});+ test("skip height inflation", () => {+ expect(call({ offsetHeight: 0, skipHeightInflation: true })).toBe("");+ });++ test("skip height inflation keeps width inflation", () => {+ expect(+ call({+ offsetWidth: 0,+ offsetHeight: 0,+ skipHeightInflation: true,+ })+ ).toBe("w");+ });+test("inflate both dimensions", () => {expect(call({ offsetWidth: 0, offsetHeight: 0 })).toBe("wh");});diff --git a/apps/builder/app/canvas/inflator.ts b/apps/builder/app/canvas/inflator.tsindex 5cf22fc59a..fb1c4d4ce6 100644--- a/apps/builder/app/canvas/inflator.ts+++ b/apps/builder/app/canvas/inflator.ts@@ -135,16 +135,22 @@ const getInflationState = ({offsetHeight,explicitWidth,explicitHeight,+ skipHeightInflation,}: {offsetWidth: number;offsetHeight: number;explicitWidth: number | undefined;explicitHeight: number | undefined;+ skipHeightInflation?: boolean;}): string => {const inflateWidth =offsetWidth === 0 && explicitWidth === undefined ? "w" : "";const inflateHeight =- offsetHeight === 0 && explicitHeight === undefined ? "h" : "";+ offsetHeight === 0 &&+ explicitHeight === undefined &&+ skipHeightInflation !== true+ ? "h"+ : "";return inflateWidth + inflateHeight;};@@ -431,6 +437,9 @@ const applyInflation = () => {offsetHeight,explicitWidth: elementSize.width,explicitHeight: elementSize.height,+ // Closed Radix-style states intentionally collapse content height+ // while keeping it mounted for animation/SEO, so avoid inflating it.+ skipHeightInflation: element.getAttribute("data-state") === "closed",});if (state) {diff --git a/packages/sdk-components-react-radix/src/__generated__/accordion.props.ts b/packages/sdk-components-react-radix/src/__generated__/accordion.props.tsindex 4f0a2a1660..3f547d482d 100644--- a/packages/sdk-components-react-radix/src/__generated__/accordion.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/accordion.props.ts@@ -63,4 +63,13 @@ export const propsAccordionItem: Record<string, PropMeta> = {};export const propsAccordionHeader: Record<string, PropMeta> = {};export const propsAccordionTrigger: Record<string, PropMeta> = {};-export const propsAccordionContent: Record<string, PropMeta> = {};+export const propsAccordionContent: Record<string, PropMeta> = {+ forceMount: {+ description:+ "Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries or keeping content available in the DOM.",+ required: false,+ control: "boolean",+ type: "boolean",+ defaultValue: true,+ },+};diff --git a/packages/sdk-components-react-radix/src/accordion.template.tsx b/packages/sdk-components-react-radix/src/accordion.template.tsxindex 43a6123714..fd1ad8ae41 100644--- a/packages/sdk-components-react-radix/src/accordion.template.tsx+++ b/packages/sdk-components-react-radix/src/accordion.template.tsx@@ -68,6 +68,7 @@ const createAccordionItem = (triggerText: string, contentText: string) => {</radix.AccordionTrigger></radix.AccordionHeader><radix.AccordionContent+ forceMount={true}// overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down// pb-4 pt-0ws:style={css`@@ -75,13 +76,10 @@ const createAccordionItem = (triggerText: string, contentText: string) => {font-size: ${fontSize.sm};line-height: ${fontSizeLineHeight.sm};transition: ${transition.all};- padding-bottom: ${spacing[4]};+ height: var(--radix-collapsible-content-height);&[data-state="closed"] {height: 0;}- &[data-state="open"] {- height: var(--radix-accordion-content-height);- }`}>{new PlaceholderValue(contentText)}diff --git a/packages/sdk-components-react-radix/src/accordion.tsx b/packages/sdk-components-react-radix/src/accordion.tsxindex 15e4c821db..b648c2d84e 100644--- a/packages/sdk-components-react-radix/src/accordion.tsx+++ b/packages/sdk-components-react-radix/src/accordion.tsx@@ -57,10 +57,15 @@ export const AccordionTrigger: ForwardRefExoticComponent<RefAttributes<HTMLButtonElement>> = Trigger;-export const AccordionContent: ForwardRefExoticComponent<- Omit<ComponentProps<typeof Content>, "asChild"> &- RefAttributes<HTMLDivElement>-> = Content;+export const AccordionContent = forwardRef<+ HTMLDivElement,+ Omit<ComponentPropsWithoutRef<typeof Content>, "asChild" | "forceMount"> & {+ forceMount?: boolean;+ }+>(({ forceMount = true, ...props }, ref) => {+ const contentProps = forceMount ? { forceMount: true as const } : {};+ return <Content ref={ref} {...contentProps} {...props} />;+});/* BUILDER HOOKS */