-
Notifications
You must be signed in to change notification settings - Fork 2
Filter non-DOM props from field widgets to prevent React warnings #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,14 +25,17 @@ export function UrlField({ value, onChange, field, readonly, errorMessage, ...pr | |
| ); | ||
| } | ||
|
|
||
| // Filter out non-DOM props | ||
| const { inputType, ...domProps } = props as any; | ||
|
|
||
|
Comment on lines
+28
to
+30
|
||
| return ( | ||
| <Input | ||
| {...props} | ||
| {...domProps} | ||
| type="url" | ||
| value={value || ''} | ||
| onChange={(e) => onChange(e.target.value)} | ||
| placeholder={config?.placeholder || 'https://example.com'} | ||
| disabled={readonly || props.disabled} | ||
| disabled={readonly || domProps.disabled} | ||
| aria-invalid={!!errorMessage} | ||
| /> | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new
inputType-filtering semantics are not currently covered by tests: the existingUrlFieldtests instandard-widgets.test.tsxnever pass aninputTypeprop or assert that it is stripped before reaching the DOM, so regressions here (e.g., accidentally re-spreadinginputType) would not be caught. Consider adding a test case that rendersUrlField(and/or the other updated widgets) with aninputTypeprop and verifies that it does not appear as an attribute on the underlying DOM element (or that React does not emit warnings via a mocked console).