Skip to content

Commit

Permalink
Merge pull request #56227 from shubham1206agra/fix-popover-accounting
Browse files Browse the repository at this point in the history
Fixed accounting popover when user have existing connections
  • Loading branch information
madmax330 authored Feb 4, 2025
2 parents 150e3d0 + 6cbe2e0 commit bfb97c5
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/components/PopoverWithMeasuredContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import isEqual from 'lodash/isEqual';
import React, {useMemo, useState} from 'react';
import type {LayoutChangeEvent} from 'react-native';
import {View} from 'react-native';
import usePrevious from '@hooks/usePrevious';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import ComposerFocusManager from '@libs/ComposerFocusManager';
Expand Down Expand Up @@ -66,23 +67,12 @@ function PopoverWithMeasuredContent({
const [popoverWidth, setPopoverWidth] = useState(popoverDimensions.width);
const [popoverHeight, setPopoverHeight] = useState(popoverDimensions.height);
const [isContentMeasured, setIsContentMeasured] = useState(popoverWidth > 0 && popoverHeight > 0);
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
const prevIsVisible = usePrevious(isVisible);

const modalId = useMemo(() => ComposerFocusManager.getId(), []);

/**
* When Popover becomes visible, we need to recalculate the Dimensions.
* Skip render on Popover until recalculations are done by setting isContentMeasured to false as early as possible.
*/
if (!isPopoverVisible && isVisible) {
if (shouldEnableNewFocusManagement) {
ComposerFocusManager.saveFocusState(modalId);
}
// When Popover is shown recalculate
setIsContentMeasured(popoverDimensions.width > 0 && popoverDimensions.height > 0);
setIsPopoverVisible(true);
} else if (isPopoverVisible && !isVisible) {
setIsPopoverVisible(false);
if (!prevIsVisible && isVisible && shouldEnableNewFocusManagement) {
ComposerFocusManager.saveFocusState(modalId);
}

/**
Expand Down Expand Up @@ -147,7 +137,7 @@ function PopoverWithMeasuredContent({
return isContentMeasured ? (
<Popover
shouldHandleNavigationBack={shouldHandleNavigationBack}
popoverDimensions={popoverDimensions}
popoverDimensions={{height: popoverHeight, width: popoverWidth}}
anchorAlignment={anchorAlignment}
isVisible={isVisible}
withoutOverlay={withoutOverlay}
Expand Down

0 comments on commit bfb97c5

Please sign in to comment.