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

[MenuItem] Fix text vertical alignment in IE 11 #17332

Merged
merged 5 commits into from
Sep 23, 2019
Merged

[MenuItem] Fix text vertical alignment in IE 11 #17332

merged 5 commits into from
Sep 23, 2019

Conversation

damir-sirola
Copy link
Contributor

@damir-sirola damir-sirola commented Sep 5, 2019

Closes #17323
Closes #17477

@mui-pr-bot
Copy link

mui-pr-bot commented Sep 5, 2019

Details of bundle changes.

Comparing: 6a1c305...653edfd

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core +0.02% 🔺 0.00% 331,822 331,878 90,593 90,593
@material-ui/core/Paper 0.00% 0.00% 68,710 68,710 20,474 20,474
@material-ui/core/Paper.esm 0.00% 0.00% 62,147 62,147 19,217 19,217
@material-ui/core/Popper 0.00% 0.00% 28,397 28,397 10,159 10,159
@material-ui/core/Textarea 0.00% 0.00% 5,082 5,082 2,136 2,136
@material-ui/core/TrapFocus 0.00% 0.00% 3,766 3,766 1,596 1,596
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 16,348 16,348 5,818 5,818
@material-ui/core/useMediaQuery 0.00% 0.00% 2,488 2,488 1,050 1,050
@material-ui/lab 0.00% 0.00% 143,172 143,172 43,751 43,751
@material-ui/styles 0.00% 0.00% 51,469 51,469 15,305 15,305
@material-ui/system 0.00% 0.00% 15,581 15,581 4,341 4,341
Button 0.00% 0.00% 78,682 78,682 24,047 24,047
Modal 0.00% 0.00% 14,542 14,542 5,113 5,113
Portal 0.00% 0.00% 2,907 2,907 1,318 1,318
Rating 0.00% 0.00% 70,013 70,013 21,867 21,867
Slider 0.00% 0.00% 75,154 75,154 23,217 23,217
colorManipulator 0.00% 0.00% 3,835 3,835 1,519 1,519
docs.landing 0.00% 0.00% 54,267 54,267 14,344 14,344
docs.main +0.01% 🔺 0.00% 581,743 581,789 186,249 186,252
packages/material-ui/build/umd/material-ui.production.min.js +0.01% 🔺 +0.02% 🔺 302,677 302,713 87,045 87,064

Generated by 🚫 dangerJS against 653edfd

@damir-sirola
Copy link
Contributor Author

damir-sirola commented Sep 5, 2019

It looks like after the change the element has minWidth of 48, but then adds padding top and bottom of 8 from ListItem. It makes menu item look huge (64px high). I recommend adding paddingTop: 0, paddingBottom: 0 on MenuItem but will await further instructions

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 5, 2019

@damir-sirola I push changes with the best alternative I can think of, I'm not very happy with the customization impact of it, but I figure that people changing the height would be happy to have IE 11 support anyway.

I recommend adding paddingTop: 0, paddingBottom: 0 on MenuItem

I think that we need to keep the padding values for the dense support.

@oliviertassinari oliviertassinari changed the title [MenuItem] Center MenuItem text vertically in Internet Explorer [MenuItem] Fix text vertical alignment in IE 11 Sep 5, 2019
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: menu This is the name of the generic UI component, not the React module! labels Sep 5, 2019
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% happy with the solution, I wish we had a better alternative. Still, considering that the menu items should, most of the time all have the same height, it's not that bad.

@ryancogswell
Copy link
Contributor

@oliviertassinari I think this change will cause way more problems than it fixes. I've seen people (in StackOverflow questions) put all sorts of things in MenuItems and anything taller than a single line of text will now get vertically cut off.

Before: https://codesandbox.io/s/wrapping-menuitem-z0utn
After: https://codesandbox.io/s/wrapping-menuitem-97ndb

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 7, 2019

@ryancogswell Do you have a recommendation on the used solution?

It seems that we are not using the right typography variant: https://material.io/components/menus/#specs. I can confirm with most of the Google products, they use a font size of 14px in all the menus, on desktop. On mobile, they seem to use 16px. So I would propose the following fix a 2-in-1:

diff --git a/packages/material-ui/src/MenuItem/MenuItem.js b/packages/material-ui/src/MenuItem/MenuItem.js
index f62a2cc9a5..a824e3b3aa 100644
--- a/packages/material-ui/src/MenuItem/MenuItem.js
+++ b/packages/material-ui/src/MenuItem/MenuItem.js
@@ -7,26 +7,27 @@ import ListItem from '../ListItem';
 export const styles = theme => ({
   /* Styles applied to the root element. */
   root: {
-    ...theme.typography.subtitle1,
+    ...theme.typography.body1,
     minHeight: 48,
-    paddingTop: 4,
-    paddingBottom: 4,
+    paddingTop: 6,
+    paddingBottom: 6,
     boxSizing: 'border-box',
     width: 'auto',
     overflow: 'hidden',
     whiteSpace: 'nowrap',
+    [theme.breakpoints.up('sm')]: {
+      ...theme.typography.body2,
+      minHeight: 'auto',
+    }
   },
+  // To remove in v5
   /* Styles applied to the root element if `disableGutters={false}`. */
-  gutters: {
-    paddingLeft: 16,
-    paddingRight: 16,
-  },
+  gutters: {},
   /* Styles applied to the root element if `selected={true}`. */
   selected: {},
+  // To remove in v5
   /* Styles applied to the root element if dense. */
-  dense: {
-    minHeight: 'auto',
-  },
+  dense: {},
 });

small screens
Capture d’écran 2019-09-07 à 10 55 10

other screens
Capture d’écran 2019-09-07 à 11 00 18

@oliviertassinari oliviertassinari added this to the v4.5.0 milestone Sep 8, 2019
@oliviertassinari oliviertassinari added the design: material This is about Material Design, please involve a visual or UX designer in the process label Sep 8, 2019
@@ -7,24 +7,27 @@ import ListItem from '../ListItem';
export const styles = theme => ({
/* Styles applied to the root element. */
root: {
...theme.typography.subtitle1,
...theme.typography.body1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs special changelog attention. It's likely this is considered a breaking change (using theme override to change MenuItem typography).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specification seems to encourage body2 but it contradicts all the implementatin of Google on mobile I can look at. I think that body1 is fine here. The intent is to use the default typography people use on the rest of the page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that body1 is fine here. The intent is to use the default typography people use on the rest of the page.

I was not talking about whether this is "fine" or "ok" or any other value judgment. Again a "breaking" change does not value the change. It simply states the implications a change has.

This change might have some which is why we should add a warning to the changelog. This is not concerned with judging this change on its merits.

Copy link
Member

@oliviertassinari oliviertassinari Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I was considering the impact of the change. The changes aim at following the spec, the breaking impact should be limited and subject to interpretation.

@oliviertassinari oliviertassinari merged commit cef3287 into mui:master Sep 23, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 23, 2019

I expect this change to be controversial, the specification multiple contradictions around what the correct size should be: https://material.io/components/menus/#specs. While the pull request started as an effort to solve IE 11 support, it has grown to something with a bigger scope.

So far, the main motivation of the change is to better match the design of Google products, I have benchmarked the changes with:

  • Gmail (height: 32px, font-size: 14px)
  • Google Contact (height: 36px, font-size: 14px)
  • Youtube (height: 36px, font-size: 14px)
  • react-select (height: 35px, font-size: 16px)
  • select2 (height: 40px, font-size: 16px)
  • Bootstrap (height: 32px, font-size 16px)
  • Bulma (height: 33px, font-size: 14px)
  • Blueprint (height: 30px, font-size: 14px)
  • Antd (height: 34px, font-size: 14px)

I hope the tradeoff is acceptable. We have height: 36px, font-size 16px. If further changes are required, we have a good week to do them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: menu This is the name of the generic UI component, not the React module! design: material This is about Material Design, please involve a visual or UX designer in the process
Projects
None yet
5 participants