From 0ec8e39051c92e90c90827018a2eeca0f4aab589 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 20 Apr 2020 16:53:22 -0500 Subject: [PATCH] Fix inline compose form clickable area, fixes #30 --- .../features/compose/components/compose_form.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/gabsocial/features/compose/components/compose_form.js b/app/gabsocial/features/compose/components/compose_form.js index 7de594479..d6e15482b 100644 --- a/app/gabsocial/features/compose/components/compose_form.js +++ b/app/gabsocial/features/compose/components/compose_form.js @@ -105,10 +105,16 @@ class ComposeForm extends ImmutablePureComponent { return clickableAreaRef ? clickableAreaRef.current : this.form; } + shouldCollapse = (e) => { + return ![ + this.getClickableArea(), + document.querySelector('.privacy-dropdown__dropdown'), + document.querySelector('.emoji-picker-dropdown__menu'), + ].some(element => element && element.contains(e.target)); + } + handleClick = (e) => { - const clickableArea = this.getClickableArea(); - if (!clickableArea) return; - if (!clickableArea.contains(e.target)) { + if (this.shouldCollapse(e)) { this.handleClickOutside(); } }