Skip to content

Commit

Permalink
use AttachmentModal's onModalShow to set the attachmentPreviewActive …
Browse files Browse the repository at this point in the history
…state
  • Loading branch information
akinwale committed May 14, 2023
1 parent 117f603 commit e782a78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const propTypes = {
/** Optional callback to fire when we want to preview an image and approve it for use. */
onConfirm: PropTypes.func,

/** Optional callback to fire when we want to do something after modal show. */
onModalShow: PropTypes.func,

/** Optional callback to fire when we want to do something after modal hide. */
onModalHide: PropTypes.func,

Expand Down Expand Up @@ -69,6 +72,7 @@ const defaultProps = {
allowDownload: false,
headerTitle: null,
reportID: '',
onModalShow: () => {},
onModalHide: () => {},
};

Expand Down Expand Up @@ -155,9 +159,6 @@ class AttachmentModal extends PureComponent {
*/
closeConfirmModal() {
this.setState({isAttachmentInvalid: false});
if (this.props.onModalHide) {
this.props.onModalHide();
}
}

/**
Expand Down Expand Up @@ -258,7 +259,10 @@ class AttachmentModal extends PureComponent {
onClose={() => this.setState({isModalOpen: false})}
isVisible={this.state.isModalOpen}
backgroundColor={themeColors.componentBG}
onModalShow={() => this.setState({shouldLoadAttachment: true})}
onModalShow={() => {
this.props.onModalShow();
this.setState({shouldLoadAttachment: true})
}}
onModalHide={(e) => {
this.props.onModalHide(e);
this.setState({shouldLoadAttachment: false});
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ class ReportActionCompose extends React.Component {
<AttachmentModal
headerTitle={this.props.translate('reportActionCompose.sendAttachment')}
onConfirm={this.addAttachment}
onModalShow={() => this.setState({isAttachmentPreviewActive: true})}
onModalHide={() => {
this.setShouldBlockEmojiCalcToFalse();
this.setState({isAttachmentPreviewActive: false});
Expand Down Expand Up @@ -1012,7 +1013,7 @@ class ReportActionCompose extends React.Component {

displayFileInModal(file);

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

0 comments on commit e782a78

Please sign in to comment.