From fce248810b74fec717b37a06217da84933fde471 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 23 Aug 2018 22:14:30 +0200 Subject: [PATCH] [Glitch] Update state when opened dropdown is unmounted Port dcd3544d153dd2a3961bd0d2214ed01a902a66da to glitch-soc --- app/javascript/flavours/glitch/components/dropdown_menu.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/javascript/flavours/glitch/components/dropdown_menu.js b/app/javascript/flavours/glitch/components/dropdown_menu.js index 27b2586e5..1c2b0bf25 100644 --- a/app/javascript/flavours/glitch/components/dropdown_menu.js +++ b/app/javascript/flavours/glitch/components/dropdown_menu.js @@ -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;