[Glitch] Update state when opened dropdown is unmounted

Port dcd3544d15 to glitch-soc
This commit is contained in:
Thibaut Girka 2018-08-23 22:14:30 +02:00 committed by ThibG
parent 8aa58e34bb
commit fce248810b

View File

@ -225,6 +225,12 @@ export default class Dropdown extends React.PureComponent {
return this.target;
}
componentWillUnmount = () => {
if (this.state.id === this.props.openDropdownId) {
this.handleClose();
}
}
render () {
const { icon, items, size, ariaLabel, disabled, dropdownPlacement, openDropdownId } = this.props;
const open = this.state.id === openDropdownId;