[Glitch] Update state when opened dropdown is unmounted

Port dcd3544d153dd2a3961bd0d2214ed01a902a66da to glitch-soc
th-downstream
Thibaut Girka 6 years ago committed by ThibG
parent 8833e0fab0
commit c4a536917c

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

Loading…
Cancel
Save