Skip to content

Commit

Permalink
Merge pull request Expensify#26851 from bernhardoj/fix/26433-composer…
Browse files Browse the repository at this point in the history
…-send-button

Fix send button is enabled when composer contains only space
  • Loading branch information
aldo-expensify authored Sep 25, 2023
2 parents e6a621a + a55d51f commit 653926d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/pages/home/report/ReportActionCompose/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import useLocalize from '../../../../hooks/useLocalize';
import getModalState from '../../../../libs/getModalState';
import useWindowDimensions from '../../../../hooks/useWindowDimensions';
import * as EmojiPickerActions from '../../../../libs/actions/EmojiPickerAction';
import getDraftComment from '../../../../libs/ComposerUtils/getDraftComment';

const propTypes = {
/** A method to call when the form is submitted */
Expand Down Expand Up @@ -103,7 +104,6 @@ function ReportActionCompose({
reportID,
reportActions,
shouldShowComposeInput,
isCommentEmpty: isCommentEmptyProp,
}) {
const {translate} = useLocalize();
const {isMediumScreenWidth, isSmallScreenWidth} = useWindowDimensions();
Expand All @@ -123,7 +123,10 @@ function ReportActionCompose({
* Updates the should clear state of the composer
*/
const [textInputShouldClear, setTextInputShouldClear] = useState(false);
const [isCommentEmpty, setIsCommentEmpty] = useState(isCommentEmptyProp);
const [isCommentEmpty, setIsCommentEmpty] = useState(() => {
const draftComment = getDraftComment(reportID);
return !draftComment || !!draftComment.match(/^(\s)*$/);
});

/**
* Updates the visibility state of the menu
Expand Down Expand Up @@ -438,10 +441,6 @@ export default compose(
withNetwork(),
withCurrentUserPersonalDetails,
withOnyx({
isCommentEmpty: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
selector: (comment) => _.isEmpty(comment),
},
blockedFromConcierge: {
key: ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE,
},
Expand Down

0 comments on commit 653926d

Please sign in to comment.