Skip to content

Commit

Permalink
fix: execute adjustXY while autoAdjust=true, adjust test specs
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 committed Nov 27, 2023
1 parent 2d170aa commit 90c31cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/placement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,13 @@ export default function getPlacements(config: PlacementsConfig): PositionResult
top = adjustResult.top;
placement = adjustResult.placement;
}
}

const adjustXYResult = adjustXY(left, top, placement, staticInfo);
if (adjustXYResult) {
left = adjustXYResult.left;
top = adjustXYResult.top;
placement = adjustXYResult.placement;
const adjustXYResult = adjustXY(left, top, placement, staticInfo);
if (adjustXYResult) {
left = adjustXYResult.left;
top = adjustXYResult.top;
placement = adjustXYResult.placement;
}
}

const result: PositionResult = {
Expand Down
8 changes: 4 additions & 4 deletions test/placement.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ describe('placement', () => {
},
adjustExpect: {
placement: 'b',
left: tLeft + target.width / 2 - overlay.width / 2,
left: Math.max(0, tLeft + target.width / 2 - overlay.width / 2),
top: tTop + target.height,
},
});
Expand All @@ -865,7 +865,7 @@ describe('placement', () => {
adjustExpect: {
placement: 'l',
left: tLeft - overlay.width,
top: tTop + target.height / 2 - overlay.height / 2,
top: Math.max(0, tTop + target.height / 2 - overlay.height / 2),
},
});
});
Expand All @@ -886,7 +886,7 @@ describe('placement', () => {
},
adjustExpect: {
placement: 't',
left: tLeft + target.width / 2 - overlay.width / 2,
left: Math.max(0, tLeft + target.width / 2 - overlay.width / 2),
top: tTop - overlay.height,
},
});
Expand All @@ -909,7 +909,7 @@ describe('placement', () => {
adjustExpect: {
placement: 'r',
left: tLeft + target.width,
top: tTop + target.height / 2 - overlay.height / 2,
top: Math.max(0, tTop + target.height / 2 - overlay.height / 2),
},
});
});
Expand Down

0 comments on commit 90c31cc

Please sign in to comment.