Skip to content

Commit

Permalink
add horizontal test
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanboXue-Amber committed Dec 16, 2024
1 parent da98ff7 commit 46f926a
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,38 @@ const ShiftToCoverTargetWithAutoSize = () => {
);
};

const ShiftToCoverTargetAsyncContentHorizontal = () => {
const styles = useStyles();
const [overflowBoundary, setOverflowBoundary] = React.useState<HTMLDivElement | null>(null);
const { containerRef, targetRef } = usePositioning({
position: 'after',
overflowBoundary,
shiftToCoverTarget: true,
autoSize: true,
});

return (
<div
ref={setOverflowBoundary}
className={styles.boundary}
style={{
height: 200,
width: 300,
padding: '50px 50px',
boxSizing: 'border-box',
position: 'relative',
}}
>
<button ref={targetRef}>Target</button>
<Box ref={containerRef} style={{ overflow: 'auto', border: '3px solid green', padding: 0 }}>
<Box style={{ maxWidth: 180 }}>
<AsyncFloatingContent />
</Box>
</Box>
</div>
);
};

const ShiftToCoverTargetAsyncContent = () => {
const styles = useStyles();
const [overflowBoundary, setOverflowBoundary] = React.useState<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -1113,3 +1145,16 @@ export const _ShiftToCoverTargetAsyncContent = () => (
</StoryWright>
);
_ShiftToCoverTargetAsyncContent.storyName = 'shiftToCoverTarget with autoSize and async content';

export const _ShiftToCoverTargetHorizontal = () => (
<StoryWright
steps={new Steps()
.click('#load-content')
.wait('#full-content')
.snapshot('floating element is within the boundary')
.end()}
>
<ShiftToCoverTargetAsyncContentHorizontal />
</StoryWright>
);
_ShiftToCoverTargetHorizontal.storyName = 'shiftToCoverTarget with autoSize and async content - horizontal';

0 comments on commit 46f926a

Please sign in to comment.