Skip to content

Commit

Permalink
Merge pull request #24543 from hoangzinh/df/23308
Browse files Browse the repository at this point in the history
Fix Popover Emoji-reacted does not close for User B when User A deletes the message
  • Loading branch information
Li357 committed Aug 15, 2023
2 parents d769b5c + e29e476 commit a90e6e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/pages/home/report/ReactionList/PopoverReactionList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<BasePopoverReactionList
Expand Down
14 changes: 9 additions & 5 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import React, {useState, useRef, useEffect, memo, useCallback} from 'react';
import React, {useState, useRef, useEffect, memo, useCallback, useContext} from 'react';
import {InteractionManager, View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -64,6 +64,7 @@ import * as PersonalDetailsUtils from '../../../libs/PersonalDetailsUtils';
import ReportActionItemBasicMessage from './ReportActionItemBasicMessage';
import * as store from '../../../libs/actions/ReimbursementAccount/store';
import * as BankAccounts from '../../../libs/actions/BankAccounts';
import ReportScreenContext from '../ReportScreenContext';
import Permissions from '../../../libs/Permissions';

const propTypes = {
Expand Down Expand Up @@ -126,24 +127,27 @@ function ReportActionItem(props) {
const [isContextMenuActive, setIsContextMenuActive] = useState(ReportActionContextMenu.isActiveReportAction(props.action.reportActionID));
const [isHidden, setIsHidden] = useState(false);
const [moderationDecision, setModerationDecision] = useState(CONST.MODERATION.MODERATOR_DECISION_APPROVED);
const {reactionListRef} = useContext(ReportScreenContext);
const textInputRef = useRef();
const popoverAnchorRef = useRef();
const downloadedPreviews = useRef([]);

useEffect(
() => () => {
// 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();
}
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;
Expand Down

0 comments on commit a90e6e0

Please sign in to comment.