diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index bac249e8715d..4e0f31c53485 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -1,6 +1,6 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; -import {View, Animated} from 'react-native'; +import {View, Animated, Keyboard} from 'react-native'; import Str from 'expensify-common/lib/str'; import lodashGet from 'lodash/get'; import lodashExtend from 'lodash/extend'; @@ -111,6 +111,17 @@ class AttachmentModal extends PureComponent { : CONST.MODAL.MODAL_TYPE.CENTERED; } + /** + * @param {String} sourceURL + */ + downloadAttachment(sourceURL) { + fileDownload(sourceURL, this.props.originalFileName); + + // At ios, if the keyboard is open while opening the attachment, then after downloading + // the attachment keyboard will show up. So, to fix it we need to dismiss the keyboard. + Keyboard.dismiss(); + } + /** * Execute the onConfirm callback and close the modal. */ @@ -250,7 +261,7 @@ class AttachmentModal extends PureComponent { title={this.props.headerTitle || this.props.translate('common.attachment')} shouldShowBorderBottom shouldShowDownloadButton={this.props.allowDownload} - onDownloadButtonPress={() => fileDownload(sourceURL, this.props.originalFileName)} + onDownloadButtonPress={() => this.downloadAttachment(sourceURL)} onCloseButtonPress={() => this.setState({isModalOpen: false})} subtitle={fileName ? (