Skip to content

Commit 93ba585

Browse files
committed
put back closeAction on component will unmount
1 parent 6681c22 commit 93ba585

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

DropdownAlert.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ export default class DropdownAlert extends Component {
179179
this.panResponder = this.getPanResponder();
180180
}
181181
componentWillUnmount() {
182-
this.clearCloseTimeoutID();
182+
if (this.state.isOpen) {
183+
this.closeAction(ACTION.programmatic);
184+
}
183185
}
184186
getPanResponder = () => {
185187
return PanResponder.create({

__tests__/DropdownAlert-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ describe('DropdownAlert component', () => {
2020
wrapper.instance().componentWillUnmount();
2121
expect(wrapper.instance().closeTimeoutID).toBeUndefined();
2222
});
23+
test('expect to close because it is open', () => {
24+
const wrapper = shallow(<DropdownAlert successImageSrc={imageSrc} />);
25+
wrapper.instance().setState({ isOpen: true });
26+
wrapper.update();
27+
wrapper.instance().componentWillUnmount();
28+
expect(wrapper.instance().state.isOpen).toBeFalsy();
29+
expect(wrapper.instance().closeTimeoutID).toBeUndefined();
30+
});
2331
});
2432
describe('getPanResponder', () => {
2533
test('expect PanResponder to be defined', () => {

0 commit comments

Comments
 (0)