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

Theme -> typography -> caption -> lineHeight is ignored #19315

Closed
2 tasks done
zsolt-dev opened this issue Jan 20, 2020 · 9 comments · Fixed by #19390
Closed
2 tasks done

Theme -> typography -> caption -> lineHeight is ignored #19315

zsolt-dev opened this issue Jan 20, 2020 · 9 comments · Fixed by #19390
Labels
component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request

Comments

@zsolt-dev
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 😯

Theme -> typography -> caption -> lineHeight is ignored

Expected Behavior 🤔

Theme -> typography -> caption -> lineHeight should not be ignored :)

Steps to Reproduce 🕹

  1. open: https://codesandbox.io/s/naughty-sun-0k7jb
  2. inspect the provided FormHelperText
  3. lineHeight is hardcoded and value from the theme is ignored

Latest stable material-ui and latest stable react

Thank you

@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Jan 20, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 20, 2020

Interesting. Yeah, I guess we can rely on the caption typography directly. What do you think of this diff?

diff --git a/packages/material-ui/src/FormHelperText/FormHelperText.js b/packages/material-ui/src/FormHelperText/FormHelperText.js
index c0da0a8e9..76660a69a 100644
--- a/packages/material-ui/src/FormHelperText/FormHelperText.js
+++ b/packages/material-ui/src/FormHelperText/FormHelperText.js
@@ -11,9 +11,7 @@ export const styles = theme => ({
     color: theme.palette.text.secondary,
     ...theme.typography.caption,
     textAlign: 'left',
-    marginTop: 8,
-    lineHeight: '1em',
-    minHeight: '1em',
+    marginTop: 4,
     margin: 0,
     '&$disabled': {
       color: theme.palette.text.disabled,
@@ -32,7 +30,8 @@ export const styles = theme => ({
   },
   /* Styles applied to the root element if `variant="filled"` or `variant="outlined"`. */
   contained: {
-    margin: '8px 14px 0',
+    marginLeft: 14,
+    marginRight: 14,
   },
   /* Pseudo-class applied to the root element if `focused={true}`. */
   focused: {},

@oliviertassinari oliviertassinari added new feature New feature or request good first issue Great for first contributions. Enable to learn the contribution process. labels Jan 20, 2020
@zsolt-dev
Copy link
Author

@oliviertassinari Looks great! Thank you for a quick response and coming up with the solution.

@oliviertassinari
Copy link
Member

Great, do you want to work on the issue?

@zsolt-dev
Copy link
Author

Thank you, but I do not understand material-ui so deeply and also do not know typescript.

Also you already did the work, so you deserve the credit for it.

@suliskh
Copy link
Contributor

suliskh commented Jan 21, 2020

Has anyone assigned to it? I am happy to help! :D

@TommyJackson85
Copy link
Contributor

@suliskh @oliviertassinari if neither of you assigned your self to this issue please let me know. I am willing to do this as my first issue attempt for this repository.

@oliviertassinari
Copy link
Member

Note that the proposed patch seems to close #19359 at the same time :), but to be confirmed.

@suliskh
Copy link
Contributor

suliskh commented Jan 25, 2020

Okay, I am going to work on the proposed patch.

@suliskh
Copy link
Contributor

suliskh commented Jan 25, 2020

Interesting. Yeah, I guess we can rely on the caption typography directly. What do you think of this diff?

diff --git a/packages/material-ui/src/FormHelperText/FormHelperText.js b/packages/material-ui/src/FormHelperText/FormHelperText.js
index c0da0a8e9..76660a69a 100644
--- a/packages/material-ui/src/FormHelperText/FormHelperText.js
+++ b/packages/material-ui/src/FormHelperText/FormHelperText.js
@@ -11,9 +11,7 @@ export const styles = theme => ({
     color: theme.palette.text.secondary,
     ...theme.typography.caption,
     textAlign: 'left',
-    marginTop: 8,
-    lineHeight: '1em',
-    minHeight: '1em',
+    marginTop: 4,
     margin: 0,
     '&$disabled': {
       color: theme.palette.text.disabled,
@@ -32,7 +30,8 @@ export const styles = theme => ({
   },
   /* Styles applied to the root element if `variant="filled"` or `variant="outlined"`. */
   contained: {
-    margin: '8px 14px 0',
+    marginLeft: 14,
+    marginRight: 14,
   },
   /* Pseudo-class applied to the root element if `focused={true}`. */
   focused: {},

The [material-design] is using pseudo-element with specified height to create gap between text field and the form text helper. The computed height of the form text helper is 19px, and the height of the pseudo-element is 16px, so I am gonna go with 3px gap.

@oliviertassinari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants