Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/material-ui/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Tooltip extends React.Component {
componentDidMount() {
warning(
!this.childrenRef.disabled ||
(this.childrenRef.disabled && this.isControlled) ||
(this.childrenRef.disabled && this.props.title === '') ||
this.childrenRef.tagName.toLowerCase() !== 'button',
[
Expand Down
17 changes: 14 additions & 3 deletions packages/material-ui/src/Tooltip/Tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ describe('<Tooltip />', () => {
});

describe('disabled button warning', () => {
before(() => {
beforeEach(() => {
consoleErrorMock.spy();
});

after(() => {
afterEach(() => {
consoleErrorMock.reset();
});

Expand All @@ -273,7 +273,7 @@ describe('<Tooltip />', () => {
assert.strictEqual(consoleErrorMock.callCount(), 0, 'should not call console.error');
});

it('should raise a warning when we can listen to events', () => {
it('should raise a warning when we are uncontrolled and can not listen to events', () => {
mount(
<Tooltip title="Hello World">
<button type="submit" disabled>
Expand All @@ -287,6 +287,17 @@ describe('<Tooltip />', () => {
/Material-UI: you are providing a disabled `button` child to the Tooltip component/,
);
});

it('should not raise a warning when we are controlled', () => {
mount(
<Tooltip title="Hello World" open>
<button type="submit" disabled>
Hello World
</button>
</Tooltip>,
);
assert.strictEqual(consoleErrorMock.callCount(), 0);
});
});

describe('prop: interactive', () => {
Expand Down