[input] Update ref type to HTMLElement#3866
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Greptile OverviewGreptile SummaryUpdated ref types from Key Changes
Issues Found
Confidence Score: 3/5
Important Files Changed
|
f2022a3 to
2b6592b
Compare
| export const FieldControl = React.forwardRef(function FieldControl( | ||
| componentProps: FieldControl.Props, | ||
| forwardedRef: React.ForwardedRef<HTMLInputElement>, | ||
| forwardedRef: React.ForwardedRef<HTMLElement>, |
There was a problem hiding this comment.
Wouldn't this be more correct?
| forwardedRef: React.ForwardedRef<HTMLElement>, | |
| forwardedRef: React.ForwardedRef<HTMLInputElement | HTMLTextAreaElement>, |
Could also update specs with testing both versions.
There was a problem hiding this comment.
I think it could actually support <div contentEditable>
The contentEditable example in FieldControl.spec.tsx:9-11 will cause runtime errors because the validation system expects elements with .validity
Regarding this comment from the bot, I don't think it really matters because TS would reject validation props passed to a div anyway?
There was a problem hiding this comment.
Yeah, good point, we can keep the added flexibility.
In any case, the user needs to define the actual type that they are passing to the component.
One minor gripe is that the default ref type (without any explicit render) is going to become more generic, even hough we know that it renders an <input>
| export const FieldControl = React.forwardRef(function FieldControl( | ||
| componentProps: FieldControl.Props, | ||
| forwardedRef: React.ForwardedRef<HTMLInputElement>, | ||
| forwardedRef: React.ForwardedRef<HTMLElement>, |
There was a problem hiding this comment.
Yeah, good point, we can keep the added flexibility.
In any case, the user needs to define the actual type that they are passing to the component.
One minor gripe is that the default ref type (without any explicit render) is going to become more generic, even hough we know that it renders an <input>
This allows
<Field.Control render={<textarea />} />without type errors when passing a ref to aHTMLTextAreaElement