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

[ToggleButton] Remove unnecessary span #27111

Merged
merged 6 commits into from
Jul 7, 2021

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Jul 4, 2021

Breaking changes

  • [ToggleButton] Remove no longer necessary span wrapper

    button > span > children exists as a workaround for flex container bug on button but not anymore, so this PR remove the span.

    • ✅ Chrome 83+ (latest 90)
    • ✅ Safari 11+ (latest 14)
    • ✅ Edge
    • ✅ Firefox 63 (latest 89)

    https://github.com/philipwalton/flexbugs#flexbug-9


Sorry, something went wrong.

@siriwatknp siriwatknp added breaking change component: toggle button This is the name of the generic UI component, not the React module! labels Jul 4, 2021
@mui-pr-bot
Copy link

mui-pr-bot commented Jul 4, 2021

Details of bundle changes (experimental)

@material-ui/core: parsed: -0.14% 😍, gzip: -0.05% 😍
@material-ui/lab: parsed: -0.18% 😍, gzip: -0.06% 😍

Generated by 🚫 dangerJS against 98fe671

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@siriwatknp siriwatknp requested a review from mnajdova July 5, 2021 01:10
@siriwatknp siriwatknp marked this pull request as ready for review July 5, 2021 01:11
@siriwatknp
Copy link
Member Author

@eps1lon @oliviertassinari @mnajdova My bad, I found that ToggleButton and Fab also has unnecessary span. Should we merge these PRs given we are already in beta? I don't think it will affect much people but it is still breaking changes.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Looks good overall.

General rule of thumb: If your PR title contains "and" it probably should be split into two PRs.
Especially if one is a feature and one is a breaking change.

@siriwatknp
Copy link
Member Author

Looks good overall.

General rule of thumb: If your PR title contains "and" it probably should be split into two PRs.
Especially if one is a feature and one is a breaking change.

Sure, will split the PR.

Comment on lines +38 to +55
})(({ theme, styleProps }) => {
const selectedColor =
styleProps.color === 'standard'
? theme.palette.text.primary
: theme.palette[styleProps.color].main;
return {
...theme.typography.button,
borderRadius: theme.shape.borderRadius,
padding: 11,
border: `1px solid ${theme.palette.divider}`,
color: theme.palette.action.active,
/* Styles applied to the root element if `fullWidth={true}`. */
...(styleProps.fullWidth && {
width: '100%',
}),
[`&.${toggleButtonClasses.disabled}`]: {
color: theme.palette.action.disabled,
border: `1px solid ${theme.palette.action.disabledBackground}`,
Copy link
Member Author

@siriwatknp siriwatknp Jul 6, 2021

Choose a reason for hiding this comment

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

This change looks hard to review, may be this explanation helps.
The change is to remove the duplicate code and combine

  • ...(styleProps.color === 'standard' &&
  • ...(styleProps.color !== 'standard' &&

into one scope with variable selectedColor (line 39) and that's all.

Copy link
Member

Choose a reason for hiding this comment

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

Hiding whitespace changes helped me a lot here.

@siriwatknp siriwatknp requested a review from eps1lon July 6, 2021 07:05
@siriwatknp siriwatknp changed the title [ToggleButton] Remove span and add color palette types [ToggleButton] Remove unnecessary span Jul 6, 2021
@siriwatknp siriwatknp merged commit 8bc4f5e into mui:next Jul 7, 2021
@siriwatknp siriwatknp deleted the fix/remove-toggle-button-span branch July 7, 2021 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: toggle button This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants