2023-02-15 14:56:22 +08:00
|
|
|
import type { TooltipProps } from 'antd';
|
|
|
|
import { Button, Tooltip, Typography } from 'antd';
|
2023-02-15 10:21:28 +08:00
|
|
|
import React from 'react';
|
2022-11-09 12:28:04 +08:00
|
|
|
|
2023-02-15 14:56:22 +08:00
|
|
|
const Block = React.forwardRef<HTMLDivElement, Partial<TooltipProps>>((props, ref) => (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
overflow: 'auto',
|
|
|
|
position: 'relative',
|
|
|
|
padding: '24px',
|
|
|
|
border: '1px solid #e9e9e9',
|
|
|
|
}}
|
|
|
|
ref={ref}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
width: '200%',
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
alignItems: 'center',
|
|
|
|
rowGap: 16,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tooltip {...props} placement="left" title="Prompt Text">
|
|
|
|
<Button>Adjust automatically / 自动调整</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip {...props} placement="left" title="Prompt Text" autoAdjustOverflow={false}>
|
|
|
|
<Button>Ignore / 不处理</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
));
|
2022-11-09 12:28:04 +08:00
|
|
|
|
2023-02-15 10:21:28 +08:00
|
|
|
const App: React.FC = () => {
|
2023-02-15 14:56:22 +08:00
|
|
|
const containerRef1 = React.useRef<HTMLDivElement>(null);
|
|
|
|
const containerRef2 = React.useRef<HTMLDivElement>(null);
|
2023-02-15 10:21:28 +08:00
|
|
|
|
|
|
|
React.useEffect(() => {
|
2023-02-15 14:56:22 +08:00
|
|
|
containerRef1.current!.scrollLeft = containerRef1.current!.clientWidth * 0.5;
|
|
|
|
containerRef2.current!.scrollLeft = containerRef2.current!.clientWidth * 0.5;
|
2023-02-15 10:21:28 +08:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
2023-02-15 14:56:22 +08:00
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', rowGap: 16 }}>
|
|
|
|
<Typography.Title level={5}>With `getPopupContainer`</Typography.Title>
|
|
|
|
<Block ref={containerRef1} getPopupContainer={(trigger) => trigger.parentElement!} />
|
|
|
|
|
|
|
|
<Typography.Title level={5}>Without `getPopupContainer`</Typography.Title>
|
|
|
|
<Block ref={containerRef2} />
|
2023-02-15 10:21:28 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
export default App;
|