Skip to content

Commit

Permalink
fix(ripple): focus style alive when disabled (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
태재영 authored and Matt Goo committed Jun 21, 2019
1 parent b2f7855 commit e222e94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/ripple/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ export function withRipple<
}
}

componentDidUpdate(prevProps: P) {
if (this.props.disabled !== prevProps.disabled && this.props.disabled) {
this.foundation.handleBlur();
}
}

componentWillUnmount() {
if (this.foundation) {
this.isComponentMounted = false;
Expand Down
13 changes: 12 additions & 1 deletion test/unit/ripple/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {SpecificEventListener} from '@material/base/types';
import {mount} from 'enzyme';
import {withRipple, InjectedProps} from '../../../packages/ripple/index';

import Button from '../../../packages/button';
import {withRipple, InjectedProps} from '../../../packages/ripple';
import {createMockRaf} from '../helpers/raf';
import {coerceForTesting} from '../helpers/types';

Expand Down Expand Up @@ -496,3 +498,12 @@ test('unmounting component does not throw errors', (done) => {
done();
});
});

test('handleBlur is called when disabled is being true', () => {
const wrapper = mount(<Button />);
const foundation = coerceForTesting<RippledComponent>(wrapper.instance())
.foundation;
foundation.handleBlur = td.func<() => void>();
wrapper.setProps({disabled: true});
td.verify(foundation.handleBlur(), {times: 1});
});

0 comments on commit e222e94

Please sign in to comment.