-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[InputLabel] Add missing component
type
#35852
Conversation
|
@ZeeshanTamboli can you please review this PR |
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.
Please add a TypeScript test case by creating a file named InputLabel.spec.tsx
.
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.
I wonder that we can simply add component
type in the InputLabelProps
interface:
--- a/packages/mui-material/src/InputLabel/InputLabel.d.ts
+++ b/packages/mui-material/src/InputLabel/InputLabel.d.ts
@@ -18,6 +18,11 @@ export interface InputLabelProps extends StandardProps<FormLabelProps> {
*/
classes?: Partial<InputLabelClasses>;
color?: FormLabelProps['color'];
+ /**
+ * The component used for the root node.
+ * Either a string to use a HTML element or a component.
+ */
+ component?: React.ElementType;
/**
* If `true`, the transition animation is disabled.
* @default false
and that would be enough instead of having all these type wrappers.
component
type issue
component
type issuecomponent
type
Then i think following test would fail and it is expected to pass. |
Oh yes. Thanks for the test. 👍 We need to get props of the component if |
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.
@sai6855 This works well 👍. But because InputLabel
inherits FormLabel
component, I realised that we need to extend the types with the Extend
keyword as per convention.
For this, as an example, you can refer to the Button
component types in Button.d.ts
file, where the Button
component inherits ButtonBase
component. You can take a look at other components as well, where one component inherits another. I am sorry; I should have said it earlier.
Ah okay, i didn't noticed there is already a convention for this use-case. As suggested migrated code as per existing convention. |
component
typecomponent
type
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.
Looks good to me! Thanks @sai6855 for your contribution.
It fixes comment #35724 (comment)
working preview: https://codesandbox.io/s/confident-ramanujan-tj1f0t?file=/demo.tsx