From 5860ab82c90f21b872aac437e85db0b95be6ef00 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Fri, 4 Jun 2021 09:02:36 +0530 Subject: [PATCH 1/4] Menu auto close --- .../home/report/ReportActionContextMenu.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionContextMenu.js b/src/pages/home/report/ReportActionContextMenu.js index 8f4079dc0d79..ae898ee5e73a 100755 --- a/src/pages/home/report/ReportActionContextMenu.js +++ b/src/pages/home/report/ReportActionContextMenu.js @@ -60,6 +60,7 @@ class ReportActionContextMenu extends React.Component { this.confirmDeleteAndHideModal = this.confirmDeleteAndHideModal.bind(this); this.hideDeleteConfirmModal = this.hideDeleteConfirmModal.bind(this); this.getActionText = this.getActionText.bind(this); + this.hidePopover = this.hidePopover.bind(this); // A list of all the context actions in this menu. this.contextActions = [ @@ -86,6 +87,7 @@ class ReportActionContextMenu extends React.Component { } else { Clipboard.setString(html); } + this.hidePopover(true); }, }, @@ -104,6 +106,7 @@ class ReportActionContextMenu extends React.Component { onPress: () => { updateLastReadActionID(this.props.reportID, this.props.reportAction.sequenceNumber); setNewMarkerPosition(this.props.reportID, this.props.reportAction.sequenceNumber); + this.hidePopover(true); }, }, @@ -112,7 +115,7 @@ class ReportActionContextMenu extends React.Component { icon: Pencil, shouldShow: () => canEditReportAction(this.props.reportAction), onPress: () => { - this.props.hidePopover(); + this.hidePopover(); saveReportActionDraft( this.props.reportID, this.props.reportAction.reportActionID, @@ -124,7 +127,9 @@ class ReportActionContextMenu extends React.Component { text: this.props.translate('reportActionContextMenu.deleteComment'), icon: Trashcan, shouldShow: () => canEditReportAction(this.props.reportAction), - onPress: () => this.setState({isDeleteCommentConfirmModalVisible: true}), + onPress: () => { + this.setState({isDeleteCommentConfirmModalVisible: true}); + }, }, ]; @@ -154,6 +159,20 @@ class ReportActionContextMenu extends React.Component { this.setState({isDeleteCommentConfirmModalVisible: false}); } + /** + * Hide the Menu + * + * @param {Boolean} delay whether the meanu should close after a delay + * @memberof ReportActionContextMenu + */ + hidePopover(delay) { + if (!delay) { + this.props.hidePopover(); + return; + } + setTimeout(this.props.hidePopover, 800); + } + render() { return this.props.isVisible && ( From 45d75c833384c90ffef1a78547739c12d32b85d8 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Fri, 4 Jun 2021 23:31:46 +0530 Subject: [PATCH 2/4] close on delete action --- src/pages/home/report/ReportActionContextMenu.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/home/report/ReportActionContextMenu.js b/src/pages/home/report/ReportActionContextMenu.js index ae898ee5e73a..b0ecd8f33df9 100755 --- a/src/pages/home/report/ReportActionContextMenu.js +++ b/src/pages/home/report/ReportActionContextMenu.js @@ -153,10 +153,12 @@ class ReportActionContextMenu extends React.Component { confirmDeleteAndHideModal() { deleteReportComment(this.props.reportID, this.props.reportAction); this.setState({isDeleteCommentConfirmModalVisible: false}); + this.hidePopover(); } hideDeleteConfirmModal() { this.setState({isDeleteCommentConfirmModalVisible: false}); + this.hidePopover(); } /** From 79a643b65dcad86535898db829a0c094d5f384c3 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 8 Jun 2021 01:01:45 +0530 Subject: [PATCH 3/4] better variable name --- src/pages/home/report/ReportActionContextMenu.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionContextMenu.js b/src/pages/home/report/ReportActionContextMenu.js index b0ecd8f33df9..23d09a984d77 100755 --- a/src/pages/home/report/ReportActionContextMenu.js +++ b/src/pages/home/report/ReportActionContextMenu.js @@ -164,11 +164,11 @@ class ReportActionContextMenu extends React.Component { /** * Hide the Menu * - * @param {Boolean} delay whether the meanu should close after a delay + * @param {Boolean} shouldDelay whether the meanu should close after a delay * @memberof ReportActionContextMenu */ - hidePopover(delay) { - if (!delay) { + hidePopover(shouldDelay) { + if (!shouldDelay) { this.props.hidePopover(); return; } From 707f7650be0dd55bd8808cb407a9944c82d7e2c6 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 8 Jun 2021 07:23:42 +0530 Subject: [PATCH 4/4] typos --- src/pages/home/report/ReportActionContextMenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionContextMenu.js b/src/pages/home/report/ReportActionContextMenu.js index 23d09a984d77..bd4ee0bc481d 100755 --- a/src/pages/home/report/ReportActionContextMenu.js +++ b/src/pages/home/report/ReportActionContextMenu.js @@ -162,9 +162,9 @@ class ReportActionContextMenu extends React.Component { } /** - * Hide the Menu + * Hides the popover menu with an optional delay * - * @param {Boolean} shouldDelay whether the meanu should close after a delay + * @param {Boolean} shouldDelay whether the menu should close after a delay * @memberof ReportActionContextMenu */ hidePopover(shouldDelay) {