Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(FormLayout): keep direction metadata authoritative (#7785)

Cindy Zhang081cceaf60c1
diff --git a/.changeset/form-layout-direction-metadata.md b/.changeset/form-layout-direction-metadata.md
new file mode 100644
index 0000000000..24378924f0
--- /dev/null
+++ b/.changeset/form-layout-direction-metadata.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Keep `FormLayout`'s direction metadata authoritative when callers pass conflicting data attributes.
+
+@cixzhang
diff --git a/packages/core/src/FormLayout/FormLayout.test.tsx b/packages/core/src/FormLayout/FormLayout.test.tsx
index 805ad93dd4..5391560002 100644
--- a/packages/core/src/FormLayout/FormLayout.test.tsx
+++ b/packages/core/src/FormLayout/FormLayout.test.tsx
@@ -71,6 +71,21 @@ describe('FormLayout', () => {
expect(el).toHaveAttribute('role', 'group');
});
+ it('keeps component-owned direction metadata over a colliding pass-through', () => {
+ render(
+ <FormLayout
+ direction="horizontal"
+ data-direction="vertical"
+ data-testid="layout">
+ content
+ </FormLayout>,
+ );
+ expect(screen.getByTestId('layout')).toHaveAttribute(
+ 'data-direction',
+ 'horizontal',
+ );
+ });
+
// ─── Direction modes ────────────────────────────────────────────────────
it('defaults to vertical direction', () => {
diff --git a/packages/core/src/FormLayout/FormLayout.tsx b/packages/core/src/FormLayout/FormLayout.tsx
index f710fc0dbc..3c4d782054 100644
--- a/packages/core/src/FormLayout/FormLayout.tsx
+++ b/packages/core/src/FormLayout/FormLayout.tsx
@@ -153,6 +153,7 @@ export function FormLayout({
<FormLayoutContext value={contextValue}>
<div
ref={ref}
+ {...props}
{...mergeProps(
themeProps('form-layout', {direction}),
stylex.props(
@@ -163,8 +164,7 @@ export function FormLayout({
),
className,
style,
- )}
- {...props}>
+ )}>
{children}
</div>
</FormLayoutContext>