From 1e3b2f853f5122eeb791eab1ecc2581be7611e3d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 17 May 2021 15:13:42 -0500 Subject: [PATCH] Composer: don't collapse if non-empty --- app/soapbox/features/compose/components/compose_form.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/soapbox/features/compose/components/compose_form.js b/app/soapbox/features/compose/components/compose_form.js index da9e142ab..899b6ae12 100644 --- a/app/soapbox/features/compose/components/compose_form.js +++ b/app/soapbox/features/compose/components/compose_form.js @@ -99,6 +99,11 @@ class ComposeForm extends ImmutablePureComponent { return clickableAreaRef ? clickableAreaRef.current : this.form; } + isEmpty = () => { + const { text, spoilerText, anyMedia } = this.props; + return !(text || spoilerText || anyMedia); + } + isClickOutside = (e) => { return ![ // List of elements that shouldn't collapse the composer when clicked @@ -111,7 +116,7 @@ class ComposeForm extends ImmutablePureComponent { } handleClick = (e) => { - if (this.isClickOutside(e)) { + if (this.isEmpty() && this.isClickOutside(e)) { this.handleClickOutside(); } } @@ -238,7 +243,7 @@ class ComposeForm extends ImmutablePureComponent { render() { const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, maxTootChars } = this.props; - const condensed = shouldCondense && !this.props.text && !this.state.composeFocused; + const condensed = shouldCondense && !this.state.composeFocused && this.isEmpty() && !this.props.isUploading; const disabled = this.props.isSubmitting; const text = [this.props.spoilerText, countableText(this.props.text)].join(''); const disabledButton = disabled || this.props.isUploading || this.props.isChangingUpload || length(text) > maxTootChars || (text.length !== 0 && text.trim().length === 0 && !anyMedia);