ant-design/components/tooltip/demo/auto-adjust-overflow.tsx
二货爱吃白萝卜 86b5c50cb4
refactor: Tooltip support auto arrow & auto shift (#40632)
* chore: adjust doc

* chore: simplify arrow offset

* chore: auto adjust shift

* docs: adjust demo

* chore: update snapshot

* chore: provide ref

* test: prepare

* chore: update deps

* test: fix part test

* test: fix part test

* test: fix part test

* test: fix part test

* test: fix part test

* test: update snapshot

* fix: missing pure render

* fix: Popover pure panel

* test: update snapshot

* test: update tour snapshot

* chore: bump trigger ver

* test: fix render ssr logic

* test: skip unnecessary case

* test: fix test case

* test: update snapshot

* test: update snapshot

* test: update snapshot

* test: update snapshot

* test: update snapshot

* test: fix test case

* test: fix test case

* chore: clean up useless warning

* test: add check for placement

* chore: ignore default
2023-02-15 10:21:28 +08:00

50 lines
1.2 KiB
TypeScript

import { Button, Tooltip } from 'antd';
import React from 'react';
const wrapStyles: React.CSSProperties = {
overflow: 'auto',
position: 'relative',
padding: '24px',
border: '1px solid #e9e9e9',
};
const App: React.FC = () => {
const containerRef = React.useRef<HTMLDivElement>(null);
React.useEffect(() => {
containerRef.current!.scrollLeft = containerRef.current!.clientWidth * 0.5;
}, []);
return (
<div style={wrapStyles} ref={containerRef}>
<div
style={{
width: '200%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
rowGap: 16,
}}
>
<Tooltip
placement="left"
title="Prompt Text"
getPopupContainer={(trigger) => trigger.parentElement!}
>
<Button>Adjust automatically / </Button>
</Tooltip>
<Tooltip
placement="left"
title="Prompt Text"
getPopupContainer={(trigger) => trigger.parentElement!}
autoAdjustOverflow={false}
>
<Button>Ignore / </Button>
</Tooltip>
</div>
</div>
);
};
export default App;