diff --git a/frontend/app/components/dropdown/dropdown.tsx b/frontend/app/components/dropdown/dropdown.tsx index 4f6500c1..10e0fe55 100644 --- a/frontend/app/components/dropdown/dropdown.tsx +++ b/frontend/app/components/dropdown/dropdown.tsx @@ -47,24 +47,19 @@ export default class Dropdown extends Component { try { const data = typeof e.data === 'string' ? JSON.parse(e.data) : e.data; - if (data.clickOutside) { - if (this.state.isActive) { - this.setState({ - isActive: false, - }); - } - } + if (!data.clickOutside) return; + if (!this.state.isActive) return; + this.setState({ + isActive: false, + }); } catch (e) {} } onOutsideClick(e: MouseEvent) { - if (this.rootNode && !this.rootNode.contains(e.target as Node)) { - if (this.state.isActive) { - this.setState({ - isActive: false, - }); - } - } + if (!this.rootNode || this.rootNode.contains(e.target as Node) || !this.state.isActive) return; + this.setState({ + isActive: false, + }); } componentDidMount() {