Skip to content
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
4 changes: 2 additions & 2 deletions packages/@react-aria/overlays/src/calculatePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export function calculatePositionInternal(
// Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
if (flip && scrollSize[size] > space) {
let flippedPlacementInfo = parsePlacement(`${FLIPPED_DIRECTION[placement]} ${crossPlacement}` as Placement);
let flippedPosition = computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, -1 * offset, crossOffset);
let flippedPosition = computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset);
let flippedSpace = getAvailableSpace(
boundaryDimensions,
containerOffsetWithBoundary,
Expand All @@ -284,7 +284,7 @@ export function calculatePositionInternal(
if (flippedSpace > space) {
placementInfo = flippedPlacementInfo;
position = flippedPosition;
normalizedOffset = -1 * offset;
normalizedOffset = offset;
}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/@react-aria/overlays/test/calculatePosition.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ describe('calculatePosition', function () {
// testCases[9] is for right placement
'left', getTargetDimension({left: 0, top: 0}), testCases[9].offsetBefore, 0, 0, true
);

describe('positive offset', function () {
checkPosition(
'left', getTargetDimension({left: 0, top: 250}), [110, 200, undefined, 100, 350], 10, 0, true
);
});
});

describe('overlay smaller than target aligns in center', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ storiesOf('DialogTrigger', module)
'shouldFlip: false',
() => renderPopover({type: 'popover', placement: 'left', shouldFlip: false, width: 'calc(100vh - 100px)'})
)
.add(
'shouldFlip: true with offset',
() => renderPopover({type: 'popover', placement: 'left', shouldFlip: true, offset: 50, width: 'calc(100vh - 100px)'})
)
.add(
'containerPadding',
() => renderPopover({type: 'popover', placement: 'bottom', width: 'calc(100vh - 100px)', containerPadding: 20})
Expand Down