diff --git a/src/pages/home/report/ReactionList/PopoverReactionList/index.js b/src/pages/home/report/ReactionList/PopoverReactionList/index.js index c39eeddb7fd..32788524984 100644 --- a/src/pages/home/report/ReactionList/PopoverReactionList/index.js +++ b/src/pages/home/report/ReactionList/PopoverReactionList/index.js @@ -29,7 +29,19 @@ function PopoverReactionList(props) { innerReactionListRef.current.showReactionList(event, reactionListAnchor); }; - useImperativeHandle(props.innerRef, () => ({showReactionList}), []); + const hideReactionList = () => { + innerReactionListRef.current.hideReactionList(); + }; + + /** + * Whether PopoverReactionList is active for the Report Action. + * + * @param {Number|String} actionID + * @return {Boolean} + */ + const isActiveReportAction = (actionID) => Boolean(actionID) && reactionListReportActionID === actionID; + + useImperativeHandle(props.innerRef, () => ({showReactionList, hideReactionList, isActiveReportAction})); return ( () => { - // ReportActionContextMenu and EmojiPicker are global component, - // we use showContextMenu and showEmojiPicker to show them, - // so we should also hide them when the current component is destroyed + // ReportActionContextMenu, EmojiPicker and PopoverReactionList are global components, + // we should also hide them when the current component is destroyed if (ReportActionContextMenu.isActiveReportAction(props.action.reportActionID)) { ReportActionContextMenu.hideContextMenu(); ReportActionContextMenu.hideDeleteModal(); @@ -142,8 +143,11 @@ function ReportActionItem(props) { if (EmojiPickerAction.isActiveReportAction(props.action.reportActionID)) { EmojiPickerAction.hideEmojiPicker(true); } + if (reactionListRef.current && reactionListRef.current.isActiveReportAction(props.action.reportActionID)) { + reactionListRef.current.hideReactionList(); + } }, - [props.action.reportActionID], + [props.action.reportActionID, reactionListRef], ); const isDraftEmpty = !props.draftMessage;