fix(tooltip): support defaultVisible for tooltip, close #8257 (#8258)

This commit is contained in:
slientcloud 2017-11-21 15:53:03 +08:00 committed by 偏右
parent 1e1baf01f6
commit 499b81f79d
3 changed files with 4 additions and 1 deletions

View File

@ -32,6 +32,7 @@ The following APIs are shared by Tooltip, Popconfirm, Popover.
| overlayStyle | Style of the tooltip card | object | - |
| placement | The position of the tooltip relative to the target, which can be one of `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | `top` |
| trigger | Tooltip trigger mode | `hover` \| `focus` \| `click` | `hover` |
| defaultVisible | Whether the floating tooltip card is visible by default | boolean | `false` |
| visible | Whether the floating tooltip card is visible or not | boolean | `false` |
| onVisibleChange | Callback executed when visibility of the tooltip card is changed | (visible) => void | - |

View File

@ -16,6 +16,7 @@ export interface AbstractTooltipProps {
overlayStyle?: React.CSSProperties;
placement?: TooltipPlacement;
builtinPlacements?: Object;
defaultVisible?: boolean;
visible?: boolean;
onVisibleChange?: (visible: boolean) => void;
mouseEnterDelay?: number;
@ -67,7 +68,7 @@ export default class Tooltip extends React.Component<TooltipProps, any> {
super(props);
this.state = {
visible: !!props.visible,
visible: !!props.visible || !!props.defaultVisible,
};
}

View File

@ -34,6 +34,7 @@ title: Tooltip
| overlayStyle | 卡片样式 | object | 无 |
| placement | 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | top |
| trigger | 触发行为,可选 `hover/focus/click` | string | hover |
| defaultVisible | 默认是否显隐 | boolean | false |
| visible | 用于手动控制浮层显隐 | boolean | false |
| onVisibleChange | 显示隐藏的回调 | (visible) => void | 无 |