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

5.0.0-alpha.21 - "styled" Button/IconButton is breaking implementations from prior version #24215

Closed
2 tasks done
mainfraame opened this issue Dec 31, 2020 · 1 comment
Closed
2 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@mainfraame
Copy link

When upgrading to the latest build, I noticed that a lot of the button styles are broken when using styled-engine (styled) to create custom button styles.

  • 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 😯

After looking into the issue, I noticed that ButtonBase now includes some reset styling: eg, padding: 0, margin: 0, border: 0, etc.

// @material-ui/core/ButtonBase/ButtonBase.js

export const ButtonBaseRoot = experimentalStyled('button', {}, {
  name: 'MuiButtonBase',
  slot: 'Root',
  overridesResolver
})({
  display: 'inline-flex',
  alignItems: 'center',
  justifyContent: 'center',
  position: 'relative',
  boxSizing: 'border-box',
  WebkitTapHighlightColor: 'transparent',
  backgroundColor: 'transparent',
  // Reset default value
  // We disable the focus ring for mouse, touch and keyboard users.
  outline: 0,
  border: 0,
  margin: 0,
  // Remove the margin in Safari
  borderRadius: 0,
  padding: 0,
  // Remove the padding in Firefox
  cursor: 'pointer',
  userSelect: 'none',
  verticalAlign: 'middle',
  MozAppearance: 'none',
  // Reset
  WebkitAppearance: 'none',
  // Reset
  textDecoration: 'none',
  // So we take precedent over the style of a native <a /> element.
  color: 'inherit',
  '&::-moz-focus-inner': {
    borderStyle: 'none' // Remove Firefox dotted outline.

  },
  '&.Mui-disabled': {
    pointerEvents: 'none',
    // Disable link interactions
    cursor: 'default'
  },
  '@media print': {
    colorAdjust: 'exact'
  }
});

Expected Behavior 🤔

It seems that switching Button (and all applicable components) over to use emotion has caused some major styling bugs for my big project. In my opinion, these properties used to "reset" the button/a element for all browsers do not belong at the component level, but should be injected via CssBaseline. Ideally, any styled (styled-engine) Button / IconButton components should work seamlessly between prior 5.0.0 versions and the current alpha release.

I believe part of this issue may be due to the change that injects some global stylings for the buttons (as mentioned in PRs). It seems to inject those global styles with precedence over any styling applied via styled from styled-engine. Maybe I'm missing something, but I am using the correct StyleProvider from styled-engine with injectFirst set to true.

Steps to Reproduce 🕹

To reproduce, simply create a styled (style-engine) Button using the previous version and the current version. You should see stark differences in padding/margin/border/etc.

Context 🔦

Your Environment 🌎

5.0.0-alpha.21

@mainfraame mainfraame added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 31, 2020
@oliviertassinari oliviertassinari added duplicate This issue or pull request already exists and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 31, 2020
@oliviertassinari
Copy link
Member

Duplicate of #24109

@oliviertassinari oliviertassinari marked this as a duplicate of #24109 Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants