Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unable to open reaction list after coming back from another chat #20739

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/Reactions/ReportActionItemReactions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useRef} from 'react';
import React, {useRef, useContext} from 'react';
import _ from 'underscore';
import {View} from 'react-native';
import PropTypes from 'prop-types';
Expand All @@ -8,10 +8,10 @@ import emojis from '../../../assets/emojis';
import AddReactionBubble from './AddReactionBubble';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '../withCurrentUserPersonalDetails';
import * as Report from '../../libs/actions/Report';
import * as ReactionList from '../../pages/home/report/ReactionList/ReactionList';
import Tooltip from '../Tooltip';
import ReactionTooltipContent from './ReactionTooltipContent';
import * as EmojiUtils from '../../libs/EmojiUtils';
import ReactionListRefContext from '../../pages/home/report/ReactionList/ReactionListRefContext';

const propTypes = {
/**
Expand Down Expand Up @@ -47,6 +47,7 @@ const defaultProps = {
};

function ReportActionItemReactions(props) {
const reactionListRef = useContext(ReactionListRefContext);
const popoverReactionListAnchor = useRef(null);
const reactionsWithCount = _.filter(props.reactions, (reaction) => reaction.users.length > 0);

Expand All @@ -67,7 +68,7 @@ function ReportActionItemReactions(props) {
};

const onReactionListOpen = (event) => {
ReactionList.showReactionList(event, popoverReactionListAnchor.current, reaction.emoji, props.reportActionID);
reactionListRef.current.showReactionList(event, popoverReactionListAnchor.current, reaction.emoji, props.reportActionID);
};

return (
Expand Down
33 changes: 0 additions & 33 deletions src/pages/home/report/ReactionList/ReactionList.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';

const ReactionListRefContext = React.createContext();
export default ReactionListRefContext;
27 changes: 15 additions & 12 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
import * as ReportUtils from '../../../libs/ReportUtils';
import reportPropTypes from '../../reportPropTypes';
import withNavigationFocus from '../../../components/withNavigationFocus';
import * as ReactionList from './ReactionList/ReactionList';
import ReactionListRefContext from './ReactionList/ReactionListRefContext';
import PopoverReactionList from './ReactionList/PopoverReactionList';
import getIsReportFullyVisible from '../../../libs/getIsReportFullyVisible';

Expand Down Expand Up @@ -65,6 +65,7 @@ class ReportActionsView extends React.Component {
this.unsubscribeVisibilityListener = null;
this.hasCachedActions = _.size(props.reportActions) > 0;

this.reactionListRef = React.createRef();
this.state = {
isFloatingMessageCounterVisible: false,
newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, props.reportActions),
Expand Down Expand Up @@ -343,18 +344,20 @@ class ReportActionsView extends React.Component {
isActive={this.state.isFloatingMessageCounterVisible && !_.isEmpty(this.state.newMarkerReportActionID)}
onClick={this.scrollToBottomAndMarkReportAsRead}
/>
<ReportActionsList
report={this.props.report}
onScroll={this.trackScroll}
onLayout={this.recordTimeToMeasureItemLayout}
sortedReportActions={this.props.reportActions}
mostRecentIOUReportActionID={this.mostRecentIOUReportActionID}
isLoadingMoreReportActions={this.props.report.isLoadingMoreReportActions}
loadMoreChats={this.loadMoreChats}
newMarkerReportActionID={this.state.newMarkerReportActionID}
/>
<ReactionListRefContext.Provider value={this.reactionListRef}>
<ReportActionsList
report={this.props.report}
onScroll={this.trackScroll}
onLayout={this.recordTimeToMeasureItemLayout}
sortedReportActions={this.props.reportActions}
mostRecentIOUReportActionID={this.mostRecentIOUReportActionID}
isLoadingMoreReportActions={this.props.report.isLoadingMoreReportActions}
loadMoreChats={this.loadMoreChats}
newMarkerReportActionID={this.state.newMarkerReportActionID}
/>
</ReactionListRefContext.Provider>
<PopoverReactionList
ref={ReactionList.reactionListRef}
ref={this.reactionListRef}
report={this.props.report}
/>
<CopySelectionHelper />
Expand Down