Skip to content
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

FormControlLabelClassKey typescript type missing a few values #17932

Closed
2 tasks done
mzbyszynski opened this issue Oct 18, 2019 · 2 comments · Fixed by #17963
Closed
2 tasks done

FormControlLabelClassKey typescript type missing a few values #17932

mzbyszynski opened this issue Oct 18, 2019 · 2 comments · Fixed by #17963
Labels
bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. hacktoberfest https://hacktoberfest.digitalocean.com/ typescript

Comments

@mzbyszynski
Copy link

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When using Typescript the compiler complains if you try to customize the following css classes on FormControlLabel:

  • labelPlacementStart
  • labelPlacementTop
  • labelPlacementBottom

Expected Behavior 🤔

You should be able to customize the above style classes as described in the documentation for FormControlLabel.

Steps to Reproduce 🕹

You can see the problem on line 21 of packages/material-ui/src/FormControlLabel/FormControlLabel.d.ts

That line currently is:

export type FormControlLabelClassKey = 'root' | 'start' | 'disabled' | 'label';

but it should be:

export type FormControlLabelClassKey = 'root' | 'start' | 'disabled' | 'label' | 'labelPlacementStart' | 'labelPlacementTop' | 'labelPlacementBottom';

Steps:

  1. use this code sandbox: https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app-with-typescript
  2. Open up the theme.tsx file.
  3. Add the following css to the theme after the palette on line 19 (make sure to include the comma so the object is valid
,
  overrides: {
    MuiFormControlLabel: {
      root: {
        color: "blue"
      },
      labelPlacementStart: {
        color: "red"
      }
    }
  }
  1. You should see the typescript compiler complain about labelPlacementStart

Context 🔦

I'm trying to customize the style of labelPlacementStart css class in the FormControlLabel component

Your Environment 🌎

Tech Version
Material-UI v4.5.1
React v16.9.0
Browser latest chrome
TypeScript 3.5.3

Let me know if you need any more information.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. typescript labels Oct 19, 2019
@oliviertassinari
Copy link
Member

@mzbyszynski Thanks for the report, what do you think of this fix?

diff --git a/packages/material-ui/src/FormControlLabel/FormControlLabel.d.ts b/packages/material-ui/src/FormControlLabel/FormControlLabel.d.ts
index 1992cfe8e..d877ddaf8 100644
--- a/packages/material-ui/src/FormControlLabel/FormControlLabel.d.ts
+++ b/packages/material-ui/src/FormControlLabel/FormControlLabel.d.ts
@@ -18,7 +18,13 @@ export interface FormControlLabelProps
   value?: unknown;
 }

-export type FormControlLabelClassKey = 'root' | 'start' | 'disabled' | 'label';
+export type FormControlLabelClassKey =
+  | 'root'
+  | 'labelPlacementStart'
+  | 'labelPlacementTop'
+  | 'labelPlacementBottom'
+  | 'disabled'
+  | 'label';

 declare const FormControlLabel: React.ComponentType<FormControlLabelProps>;

@oliviertassinari oliviertassinari added the hacktoberfest https://hacktoberfest.digitalocean.com/ label Oct 19, 2019
@mzbyszynski
Copy link
Author

@oliviertassinari Thank you! 🎃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. hacktoberfest https://hacktoberfest.digitalocean.com/ typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants