Skip to content

Commit bb390e2

Browse files
authored
fix: form attribute spread prevention (#905)
1 parent 2bc000c commit bb390e2

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

.changeset/f5h6b0cx9ra.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Fix form fields to prevent internal `form` prop from being spread to DOM elements

.cursor/rules/changeset.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: When user asked to add a changeset
33
alwaysApply: false
44
---
55

6-
Place the changeset in the `/.changeset` folder.
6+
Add changeset manually. Place the changeset in the `/.changeset` folder.
77

88
## Version Selection
99
- Use `patch` for bug fixes and small changes (even with minor breaking changes)

src/components/fields/TextInput/TextInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const TextInput = forwardRef(function TextInput(
3232
let {
3333
labelProps: userLabelProps,
3434
inputRef: propsInputRef,
35+
form,
3536
...restProps
3637
} = props;
3738
let localInputRef = useRef<HTMLTextAreaElement | HTMLInputElement>(null);

src/components/form/Form/use-field/use-field-props.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ export function useFieldProps<
133133
? field.field.errors[0]
134134
: undefined;
135135

136+
// Exclude 'form' from field to prevent it from being spread to DOM elements
137+
const { form: _form, ...fieldWithoutForm } = field ?? {};
138+
136139
const result: Props = isOutsideOfForm
137140
? props
138-
: mergeProps(props, field, valueProps, {
141+
: mergeProps(props, fieldWithoutForm, valueProps, {
139142
validateTrigger: field.validateTrigger ?? defaultValidationTrigger,
140143
onBlur: onBlurChained,
141144
errorMessage: compiledErrorMessage,

0 commit comments

Comments
 (0)