Skip to content

Commit 11d4b20

Browse files
authored
fix(ui): prevent unknown props from leaking to DOM in CodeEditorField (#269)
Remove `extends React.ComponentPropsWithoutRef<'div'>` and spread props pattern that was causing unknown props (like contractSchema, adapter) to leak to the DOM element, triggering React warnings. The component now explicitly defines only the props it needs, making it more defensive and app-agnostic.
1 parent e00f7ca commit 11d4b20

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/ui/src/components/fields/CodeEditorField.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ import { ErrorMessage } from './utils';
88
/**
99
* CodeEditorField component properties
1010
*/
11-
export interface CodeEditorFieldProps<TFieldValues extends FieldValues = FieldValues>
12-
extends React.ComponentPropsWithoutRef<'div'> {
11+
export interface CodeEditorFieldProps<TFieldValues extends FieldValues = FieldValues> {
1312
/**
1413
* Unique identifier for the field
1514
*/
1615
id: string;
1716

17+
/**
18+
* Optional CSS class name for the container
19+
*/
20+
className?: string;
21+
1822
/**
1923
* Field name for form control
2024
*/
@@ -126,7 +130,6 @@ export function CodeEditorField<TFieldValues extends FieldValues = FieldValues>(
126130
readOnly = false,
127131
validateCode,
128132
className,
129-
...props
130133
}: CodeEditorFieldProps<TFieldValues>): React.ReactElement {
131134
// Convert height strings to numbers for native props with robust parsing
132135
function extractPixelValue(val: string | number, fallback: number): number {
@@ -139,7 +142,7 @@ export function CodeEditorField<TFieldValues extends FieldValues = FieldValues>(
139142
const maxHeightNum = extractPixelValue(maxHeight, 400);
140143

141144
return (
142-
<div className={className} {...props}>
145+
<div className={className}>
143146
{label && (
144147
<label htmlFor={id} className="block text-sm font-medium text-foreground mb-2">
145148
{label}

0 commit comments

Comments
 (0)