diff --git a/src/FlatButton/FlatButton.js b/src/FlatButton/FlatButton.js
index 0830f6ff25407b..8704c1da9a7d6f 100644
--- a/src/FlatButton/FlatButton.js
+++ b/src/FlatButton/FlatButton.js
@@ -118,7 +118,7 @@ class FlatButton extends Component {
};
componentWillReceiveProps(nextProps) {
- if (nextProps.disabled && this.state.hovered) {
+ if (nextProps.disabled) {
this.setState({
hovered: false,
});
diff --git a/src/FloatingActionButton/FloatingActionButton.js b/src/FloatingActionButton/FloatingActionButton.js
index 56bac099c96cc6..4d103d1b2e46b3 100644
--- a/src/FloatingActionButton/FloatingActionButton.js
+++ b/src/FloatingActionButton/FloatingActionButton.js
@@ -164,11 +164,16 @@ class FloatingActionButton extends Component {
}
componentWillReceiveProps(nextProps) {
+ const nextState = {};
+
if (nextProps.disabled !== this.props.disabled) {
- this.setState({
- zDepth: nextProps.disabled ? 0 : this.props.zDepth,
- });
+ nextState.zDepth = nextProps.disabled ? 0 : this.props.zDepth;
+ }
+ if (nextProps.disabled) {
+ nextState.hovered = false;
}
+
+ this.setState(nextState);
}
handleMouseDown = (event) => {
diff --git a/src/FloatingActionButton/FloatingActionButton.spec.js b/src/FloatingActionButton/FloatingActionButton.spec.js
new file mode 100644
index 00000000000000..ebe7e41fef5e05
--- /dev/null
+++ b/src/FloatingActionButton/FloatingActionButton.spec.js
@@ -0,0 +1,30 @@
+/* eslint-env mocha */
+import React from 'react';
+import {shallow} from 'enzyme';
+import {assert} from 'chai';
+
+import FloatingActionButton from './FloatingActionButton';
+import getMuiTheme from '../styles/getMuiTheme';
+import ContentAdd from '../svg-icons/content/add';
+
+describe('', () => {
+ const muiTheme = getMuiTheme();
+ const shallowWithContext = (node) => shallow(node, {context: {muiTheme}});
+
+ describe('hover state', () => {
+ it('should reset the hover state when disabled', () => {
+ const wrapper = shallowWithContext(
+
+
+
+ );
+ wrapper.setState({
+ hovered: true,
+ });
+ wrapper.setProps({
+ disabled: true,
+ });
+ assert.strictEqual(wrapper.state().hovered, false, 'should reset the state');
+ });
+ });
+});
diff --git a/src/RaisedButton/RaisedButton.js b/src/RaisedButton/RaisedButton.js
index 9f4552ee35f452..43063003347f9e 100644
--- a/src/RaisedButton/RaisedButton.js
+++ b/src/RaisedButton/RaisedButton.js
@@ -243,7 +243,7 @@ class RaisedButton extends Component {
initialZDepth: zDepth,
};
- if (nextProps.disabled && this.state.hovered) {
+ if (nextProps.disabled) {
nextState.hovered = false;
}