fix: Tooltip arrowPointAtCenter 1px shift bug (#31201)

close #31197
This commit is contained in:
afc163 2021-06-30 11:48:11 +08:00 committed by GitHub
parent 7a10ed1e12
commit 19cd3519dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 18 deletions

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders ./components/popover/demo/arrow-point-at-center.md correctly 1`] = `
<div>
Array [
<button
class="ant-btn"
type="button"
@ -9,7 +9,7 @@ exports[`renders ./components/popover/demo/arrow-point-at-center.md correctly 1`
<span>
Align edge / 边缘对齐
</span>
</button>
</button>,
<button
class="ant-btn"
type="button"
@ -17,8 +17,8 @@ exports[`renders ./components/popover/demo/arrow-point-at-center.md correctly 1`
<span>
Arrow points to center / 箭头指向中心
</span>
</button>
</div>
</button>,
]
`;
exports[`renders ./components/popover/demo/basic.md correctly 1`] = `

View File

@ -16,23 +16,22 @@ The arrow points to the center of the target element, which set `arrowPointAtCen
```jsx
import { Popover, Button } from 'antd';
const text = <span>Title</span>;
const content = (
<div>
<>
<p>Content</p>
<p>Content</p>
</div>
</>
);
ReactDOM.render(
<div>
<Popover placement="topLeft" title={text} content={content}>
<>
<Popover placement="topLeft" title="Title" content={content}>
<Button>Align edge / 边缘对齐</Button>
</Popover>
<Popover placement="topLeft" title={text} content={content} arrowPointAtCenter>
<Popover placement="topLeft" title="Title" content={content} arrowPointAtCenter>
<Button>Arrow points to center / 箭头指向中心</Button>
</Popover>
</div>,
</>,
mountNode,
);
```

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders ./components/tooltip/demo/arrow-point-at-center.md correctly 1`] = `
<div>
Array [
<button
class="ant-btn"
type="button"
@ -9,7 +9,7 @@ exports[`renders ./components/tooltip/demo/arrow-point-at-center.md correctly 1`
<span>
Align edge / 边缘对齐
</span>
</button>
</button>,
<button
class="ant-btn"
type="button"
@ -17,8 +17,8 @@ exports[`renders ./components/tooltip/demo/arrow-point-at-center.md correctly 1`
<span>
Arrow points to center / 箭头指向中心
</span>
</button>
</div>
</button>,
]
`;
exports[`renders ./components/tooltip/demo/auto-adjust-overflow.md correctly 1`] = `

View File

@ -17,14 +17,14 @@ By specifying `arrowPointAtCenter` prop, the arrow will point to the center of t
import { Tooltip, Button } from 'antd';
ReactDOM.render(
<div>
<>
<Tooltip placement="topLeft" title="Prompt Text">
<Button>Align edge / 边缘对齐</Button>
</Tooltip>
<Tooltip placement="topLeft" title="Prompt Text" arrowPointAtCenter>
<Button>Arrow points to center / 箭头指向中心</Button>
</Tooltip>
</div>,
</>,
mountNode,
);
```

View File

@ -38,7 +38,7 @@ export function getOverflowOptions(autoAdjustOverflow?: boolean | AdjustOverflow
export default function getPlacements(config: PlacementsConfig) {
const {
arrowWidth = 5,
arrowWidth = 4,
horizontalArrowShift = 16,
verticalArrowShift = 8,
autoAdjustOverflow,