Skip to content
Merged
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
16 changes: 14 additions & 2 deletions src/components/PopoverWithMeasuredContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ComposerFocusManager from '@libs/ComposerFocusManager';
import PopoverWithMeasuredContentUtils from '@libs/PopoverWithMeasuredContentUtils';
import CONST from '@src/CONST';
import type {AnchorDimensions, AnchorPosition} from '@src/styles';
import type {PopoverAnchorPosition} from './Modal/types';
import Popover from './Popover';
import type PopoverProps from './Popover/types';

Expand Down Expand Up @@ -76,6 +77,10 @@ function PopoverWithMeasuredContent({
ComposerFocusManager.saveFocusState(modalId);
}

if (!prevIsVisible && isVisible && isContentMeasured) {
setIsContentMeasured(false);
}

/**
* Measure the size of the popover's content.
*/
Expand Down Expand Up @@ -130,11 +135,18 @@ function PopoverWithMeasuredContent({
anchorDimensions.height,
shoudSwitchPositionIfOverflow,
);
const shiftedAnchorPosition = {
const shiftedAnchorPosition: PopoverAnchorPosition = {
left: adjustedAnchorPosition.left + horizontalShift,
bottom: windowHeight - (adjustedAnchorPosition.top + popoverHeight) - verticalShift,
};

if (anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP) {
shiftedAnchorPosition.top = adjustedAnchorPosition.top;
}

if (anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM) {
shiftedAnchorPosition.bottom = windowHeight - (adjustedAnchorPosition.top + popoverHeight) - verticalShift;
}

return isContentMeasured ? (
<Popover
shouldHandleNavigationBack={shouldHandleNavigationBack}
Expand Down