Skip to content

Commit

Permalink
Merge pull request Expensify#18624 from akinwale/task-18210
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam authored May 9, 2023
2 parents 0eb6495 + 70e0eec commit d516b63
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class ReportActionCompose extends React.Component {
this.showPopoverMenu = this.showPopoverMenu.bind(this);
this.comment = props.comment;
this.setShouldBlockEmojiCalcToFalse = this.setShouldBlockEmojiCalcToFalse.bind(this);
this.attachmentPreviewClosed = this.attachmentPreviewClosed.bind(this);

// React Native will retain focus on an input for native devices but web/mWeb behave differently so we have some focus management
// code that will refocus the compose input after a user closes a modal or some other actions, see usage of ReportActionComposeFocusManager
Expand Down Expand Up @@ -214,6 +215,7 @@ class ReportActionCompose extends React.Component {
isEmojiPickerLarge: false,
composerHeight: 0,
hasExceededMaxCommentLength: false,
isAttachmentPreviewActive: false,
};
}

Expand Down Expand Up @@ -747,6 +749,14 @@ class ReportActionCompose extends React.Component {
return true;
}

/**
* Event handler to update the state after the attachment preview is closed.
*/
attachmentPreviewClosed() {
this.setShouldBlockEmojiCalcToFalse();
this.setState({isAttachmentPreviewActive: false});
}

render() {
const reportParticipants = _.without(lodashGet(this.props.report, 'participants', []), this.props.currentUserPersonalDetails.login);
const participantsWithoutExpensifyEmails = _.difference(reportParticipants, CONST.EXPENSIFY_EMAILS);
Expand Down Expand Up @@ -787,7 +797,7 @@ class ReportActionCompose extends React.Component {
<AttachmentModal
headerTitle={this.props.translate('reportActionCompose.sendAttachment')}
onConfirm={this.addAttachment}
onModalHide={this.setShouldBlockEmojiCalcToFalse}
onModalHide={this.attachmentPreviewClosed}
>
{({displayFileInModal}) => (
<>
Expand Down Expand Up @@ -892,12 +902,16 @@ class ReportActionCompose extends React.Component {
}}
onDrop={(e) => {
e.preventDefault();
if (this.state.isAttachmentPreviewActive) {
this.setState({isDraggingOver: false});
return;
}

const file = lodashGet(e, ['dataTransfer', 'files', 0]);

displayFileInModal(file);

this.setState({isDraggingOver: false});
this.setState({isAttachmentPreviewActive: true, isDraggingOver: false});
}}
disabled={this.props.disabled}
>
Expand Down

0 comments on commit d516b63

Please sign in to comment.