mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.92k stars 32.27k forks source link

[ButtonGroup] Disable Button <span> wrapper + Tooltip incompatibility #21313

Closed qkdreyer closed 4 years ago

qkdreyer commented 4 years ago

Current Behavior 😯

Expected Behavior 🤔

Steps to Reproduce 🕹

https://codesandbox.io/s/old-night-n2z35

Steps:

  1. Check the disabled button is missing its style from ButtonGroup
  2. Open the console and view React warnings

Context 🔦

Just using multiple Mui components

Your Environment 🌎

Tech Version
Material-UI v4.10.1
React v16.13.1
Browser Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
oliviertassinari commented 4 years ago

@qkdreyer We can't do much better than:

import React from "react";
import { ButtonGroup, Tooltip, Button } from "@material-ui/core";

function Wire({ children, ...other }) {
  return children(other);
}

/**
 * how you used the components
 */
export default function Demo() {
  return (
    <ButtonGroup>
      <Wire>
        {props => (
          <Tooltip title="You don't have permission to do this">
            <span>
              <Button {...props} disabled>
                A Disabled Button
              </Button>
            </span>
          </Tooltip>
        )}
      </Wire>
      <Button>A Button</Button>
    </ButtonGroup>
  );
}

https://codesandbox.io/s/busy-poitras-rh26y?file=/src/Demo.js:0-606

Closing as we are technically limited. If not enough, you would need to rewrite the component, changing the design tradeoff.

qkdreyer commented 4 years ago

That's a great fix for the unwired props, but we're still missing some style from the ButtonGroup children (look at the missing border-radius) :

image

Is there any workaround about that ?

oliviertassinari commented 4 years ago

It's what I meant by "limited".