Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Hide emojiPicker when composer is hidden #21376

Merged
merged 9 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,16 @@ function getParentReport(report) {
return lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`, {});
}

/**
* Return true if the composer should be hidden
* @param {Object} report
* @param {Object} reportErrors
* @returns {Boolean}
*/
function shouldHideComposer(report, reportErrors) {
return isArchivedRoom(report) || !_.isEmpty(reportErrors) || !isAllowedToComment(report);
}

/**
* Returns ID of the original report from which the given reportAction is first created.
*
Expand Down Expand Up @@ -2361,5 +2371,6 @@ export {
getMoneyRequestAction,
getBankAccountRoute,
getParentReport,
shouldHideComposer,
getOriginalReportID,
};
4 changes: 4 additions & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class ReportScreen extends React.Component {
}

componentDidUpdate(prevProps) {
// If composer should be hidden, hide emoji picker as well
if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) {
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
EmojiPickerAction.hideEmojiPicker(true);
}
// If you already have a report open and are deeplinking to a new report on native,
// the ReportScreen never actually unmounts and the reportID in the route also doesn't change.
// Therefore, we need to compare if the existing reportID is the same as the one in the route
Expand Down
4 changes: 1 addition & 3 deletions src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import _ from 'underscore';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import {View, Keyboard} from 'react-native';
Expand Down Expand Up @@ -60,8 +59,7 @@ const defaultProps = {
function ReportFooter(props) {
const chatFooterStyles = {...styles.chatFooter, minHeight: !props.isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0};
const isArchivedRoom = ReportUtils.isArchivedRoom(props.report);
const isAllowedToComment = ReportUtils.isAllowedToComment(props.report);
const hideComposer = isArchivedRoom || !_.isEmpty(props.errors) || !isAllowedToComment;
const hideComposer = ReportUtils.shouldHideComposer(props.report, props.errors);

return (
<>
Expand Down