偏右
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
20 additions and
4 deletions
-
components/tooltip/__tests__/tooltip.test.js
-
components/tooltip/index.tsx
|
|
@ -241,4 +241,14 @@ describe('Tooltip', () => { |
|
|
|
expect(onVisibleChange).toHaveBeenCalledWith(false); |
|
|
|
expect(wrapper.instance().tooltip.props.visible).toBe(false); |
|
|
|
}); |
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/20891
|
|
|
|
it('should display zero', async () => { |
|
|
|
const wrapper = mount( |
|
|
|
<Tooltip title={0} visible> |
|
|
|
<div /> |
|
|
|
</Tooltip>, |
|
|
|
); |
|
|
|
expect(wrapper.find('.ant-tooltip-inner').getDOMNode().innerHTML).toBe('0'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
@ -226,7 +226,15 @@ class Tooltip extends React.Component<TooltipProps, any> { |
|
|
|
|
|
|
|
isNoTitle() { |
|
|
|
const { title, overlay } = this.props; |
|
|
|
return !title && !overlay; // overlay for old version compatibility
|
|
|
|
return !title && !overlay && title !== 0; // overlay for old version compatibility
|
|
|
|
} |
|
|
|
|
|
|
|
getOverlay() { |
|
|
|
const { title, overlay } = this.props; |
|
|
|
if (title === 0) { |
|
|
|
return title; |
|
|
|
} |
|
|
|
return overlay || title || ''; |
|
|
|
} |
|
|
|
|
|
|
|
renderTooltip = ({ |
|
|
@ -236,8 +244,6 @@ class Tooltip extends React.Component<TooltipProps, any> { |
|
|
|
const { props, state } = this; |
|
|
|
const { |
|
|
|
prefixCls: customizePrefixCls, |
|
|
|
title, |
|
|
|
overlay, |
|
|
|
openClassName, |
|
|
|
getPopupContainer, |
|
|
|
getTooltipContainer, |
|
|
@ -266,7 +272,7 @@ class Tooltip extends React.Component<TooltipProps, any> { |
|
|
|
getTooltipContainer={getPopupContainer || getTooltipContainer || getContextPopupContainer} |
|
|
|
ref={this.saveTooltip} |
|
|
|
builtinPlacements={this.getPlacements()} |
|
|
|
overlay={overlay || title || ''} |
|
|
|
overlay={this.getOverlay()} |
|
|
|
visible={visible} |
|
|
|
onVisibleChange={this.onVisibleChange} |
|
|
|
onPopupAlign={this.onPopupAlign} |
|
|
|