Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit e222e94

Browse files
태재영Matt Goo
authored andcommitted
fix(ripple): focus style alive when disabled (#943)
1 parent b2f7855 commit e222e94

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/ripple/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ export function withRipple<
146146
}
147147
}
148148

149+
componentDidUpdate(prevProps: P) {
150+
if (this.props.disabled !== prevProps.disabled && this.props.disabled) {
151+
this.foundation.handleBlur();
152+
}
153+
}
154+
149155
componentWillUnmount() {
150156
if (this.foundation) {
151157
this.isComponentMounted = false;

test/unit/ripple/index.test.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {MDCRippleFoundation} from '@material/ripple/foundation';
55
import {MDCRippleAdapter} from '@material/ripple/adapter';
66
import {SpecificEventListener} from '@material/base/types';
77
import {mount} from 'enzyme';
8-
import {withRipple, InjectedProps} from '../../../packages/ripple/index';
8+
9+
import Button from '../../../packages/button';
10+
import {withRipple, InjectedProps} from '../../../packages/ripple';
911
import {createMockRaf} from '../helpers/raf';
1012
import {coerceForTesting} from '../helpers/types';
1113

@@ -496,3 +498,12 @@ test('unmounting component does not throw errors', (done) => {
496498
done();
497499
});
498500
});
501+
502+
test('handleBlur is called when disabled is being true', () => {
503+
const wrapper = mount(<Button />);
504+
const foundation = coerceForTesting<RippledComponent>(wrapper.instance())
505+
.foundation;
506+
foundation.handleBlur = td.func<() => void>();
507+
wrapper.setProps({disabled: true});
508+
td.verify(foundation.handleBlur(), {times: 1});
509+
});

0 commit comments

Comments
 (0)