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 LHN - Click and long pressing a user report with lots of messages opens popover inside report #27904

17 changes: 16 additions & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import _ from 'underscore';
import React, {useState, useRef} from 'react';
import React, {useState, useRef, useCallback} from 'react';
import PropTypes from 'prop-types';
import {View, StyleSheet} from 'react-native';
import lodashGet from 'lodash/get';
import {useFocusEffect} from '@react-navigation/native';
import * as optionRowStyles from '../../styles/optionRowStyles';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
Expand All @@ -25,6 +26,7 @@
import useLocalize from '../../hooks/useLocalize';
import Permissions from '../../libs/Permissions';
import Tooltip from '../Tooltip';
import useWindowDimensions from '../../hooks/useWindowDimensions';

const propTypes = {
/** Style for hovered state */
Expand Down Expand Up @@ -65,6 +67,8 @@

function OptionRowLHN(props) {
const popoverAnchor = useRef(null);
const isFocusedRef = useRef(true);
const {isSmallScreenWidth} = useWindowDimensions();

const {translate} = useLocalize();

Expand Down Expand Up @@ -104,15 +108,26 @@
const shouldShowGreenDotIndicator =
!hasBrickError &&
(optionItem.isUnreadWithMention ||
ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem) ||

Check failure on line 111 in src/components/LHNOptionsList/OptionRowLHN.js

View workflow job for this annotation

GitHub Actions / lint

React Hook "useFocusEffect" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(optionItem.isTaskReport && optionItem.isTaskAssignee && !optionItem.isCompletedTaskReport && !optionItem.isArchivedRoom));

Check failure on line 112 in src/components/LHNOptionsList/OptionRowLHN.js

View workflow job for this annotation

GitHub Actions / lint

React Hook "useCallback" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?

useFocusEffect(
useCallback(() => {
isFocusedRef.current = true;
return () => {
isFocusedRef.current = false;
};
}, []),
);
/**
* Show the ReportActionContextMenu modal popover.
*
* @param {Object} [event] - A press event.
*/
const showPopover = (event) => {
if (!isFocusedRef.current && isSmallScreenWidth) {
return;
}
setIsContextMenuActive(true);
ReportActionContextMenu.showContextMenu(
ContextMenuActions.CONTEXT_MENU_TYPES.REPORT,
Expand Down
1 change: 1 addition & 0 deletions tests/utils/LHNTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.mock('@react-navigation/native', () => {
const actualNav = jest.requireActual('@react-navigation/native');
return {
...actualNav,
useFocusEffect: jest.fn(),
useIsFocused: () => ({
navigate: mockedNavigate,
}),
Expand Down
Loading