From 12bed4ff951665a2d99329329797f056ee6450c4 Mon Sep 17 00:00:00 2001 From: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> Date: Tue, 14 Nov 2023 18:26:38 +0600 Subject: [PATCH] Revert "fixes the issue #29379" --- .../EmojiPicker/EmojiPickerButton.js | 7 +-- .../AttachmentPickerWithMenuItems.js | 55 +++---------------- 2 files changed, 10 insertions(+), 52 deletions(-) diff --git a/src/components/EmojiPicker/EmojiPickerButton.js b/src/components/EmojiPicker/EmojiPickerButton.js index ddfa6b89c899..ab9daf3f0cb1 100644 --- a/src/components/EmojiPicker/EmojiPickerButton.js +++ b/src/components/EmojiPicker/EmojiPickerButton.js @@ -5,8 +5,6 @@ import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import Tooltip from '@components/Tooltip/PopoverAnchorTooltip'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; -import withNavigationFocus from '@components/withNavigationFocus'; -import compose from '@libs/compose'; import getButtonState from '@libs/getButtonState'; import styles from '@styles/styles'; import * as StyleUtils from '@styles/StyleUtils'; @@ -43,9 +41,6 @@ function EmojiPickerButton(props) { style={({hovered, pressed}) => [styles.chatItemEmojiButton, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed))]} disabled={props.isDisabled} onPress={() => { - if (!props.isFocused) { - return; - } if (!EmojiPickerAction.emojiPickerRef.current.isEmojiPickerVisible) { EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor.current, undefined, () => {}, props.emojiPickerID); } else { @@ -69,4 +64,4 @@ function EmojiPickerButton(props) { EmojiPickerButton.propTypes = propTypes; EmojiPickerButton.defaultProps = defaultProps; EmojiPickerButton.displayName = 'EmojiPickerButton'; -export default compose(withLocalize, withNavigationFocus)(EmojiPickerButton); +export default withLocalize(EmojiPickerButton); diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js index 6ab09a5a1bd4..a8ecff7c8d82 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React, {useCallback, useEffect, useMemo} from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; @@ -9,12 +9,9 @@ import * as Expensicons from '@components/Icon/Expensicons'; import PopoverMenu from '@components/PopoverMenu'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Tooltip from '@components/Tooltip/PopoverAnchorTooltip'; -import withNavigationFocus from '@components/withNavigationFocus'; import useLocalize from '@hooks/useLocalize'; -import usePrevious from '@hooks/usePrevious'; import useWindowDimensions from '@hooks/useWindowDimensions'; import * as Browser from '@libs/Browser'; -import compose from '@libs/compose'; import Permissions from '@libs/Permissions'; import * as ReportUtils from '@libs/ReportUtils'; import styles from '@styles/styles'; @@ -87,9 +84,6 @@ const propTypes = { // eslint-disable-next-line react/forbid-prop-types current: PropTypes.object, }).isRequired, - - /** Whether navigation is focused */ - isFocused: PropTypes.bool.isRequired, }; const defaultProps = { @@ -122,7 +116,6 @@ function AttachmentPickerWithMenuItems({ onAddActionPressed, onItemSelected, actionButtonRef, - isFocused, }) { const {translate} = useLocalize(); const {windowHeight} = useWindowDimensions(); @@ -171,33 +164,10 @@ function AttachmentPickerWithMenuItems({ ]; }, [betas, report, reportID, translate]); - const onPopoverMenuClose = useCallback(() => { + const onPopoverMenuClose = () => { setMenuVisibility(false); onMenuClosed(); - }, [onMenuClosed, setMenuVisibility]); - - const prevIsFocused = usePrevious(isFocused); - - /** - * Check if current screen is inactive and previous screen is active. - * Used to close already opened popover menu when any other page is opened over current page. - * - * @return {Boolean} - */ - const didScreenBecomeInactive = useCallback( - () => - // When any other page is opened over LHN - !isFocused && prevIsFocused, - [isFocused, prevIsFocused], - ); - - // When the navigation is focused, we want to close the popover menu. - useEffect(() => { - if (!didScreenBecomeInactive()) { - return; - } - onPopoverMenuClose(); - }, [didScreenBecomeInactive, onPopoverMenuClose]); + }; return ( @@ -269,10 +239,6 @@ function AttachmentPickerWithMenuItems({ ref={actionButtonRef} onPress={(e) => { e.preventDefault(); - if (!isFocused) { - return; - } - onAddActionPressed(); // Drop focus to avoid blue focus ring. @@ -290,7 +256,7 @@ function AttachmentPickerWithMenuItems({ { setMenuVisibility(false); @@ -320,11 +286,8 @@ AttachmentPickerWithMenuItems.propTypes = propTypes; AttachmentPickerWithMenuItems.defaultProps = defaultProps; AttachmentPickerWithMenuItems.displayName = 'AttachmentPickerWithMenuItems'; -export default compose( - withNavigationFocus, - withOnyx({ - betas: { - key: ONYXKEYS.BETAS, - }, - }), -)(AttachmentPickerWithMenuItems); +export default withOnyx({ + betas: { + key: ONYXKEYS.BETAS, + }, +})(AttachmentPickerWithMenuItems);