diff --git a/.gitignore b/.gitignore
index 93e1cbd..e466542 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,5 @@ package-lock.json
.dumi/tmp
.dumi/tmp-production
-bun.lockb
\ No newline at end of file
+bun.lockb
+.vscode/
\ No newline at end of file
diff --git a/docs/examples/formError.tsx b/docs/examples/formError.tsx
index cec8845..5b317b0 100644
--- a/docs/examples/formError.tsx
+++ b/docs/examples/formError.tsx
@@ -4,13 +4,13 @@ import React, { Component } from 'react';
import '../../assets/bootstrap.less';
interface TestState {
- visible: boolean;
+ open: boolean;
destroy?: boolean;
}
class Test extends Component {
state = {
- visible: false,
+ open: false,
} as TestState;
handleDestroy = () => {
@@ -33,7 +33,7 @@ class Test extends Component {
{
+ onOpenChange = visible => {
this.setState({
visible,
});
@@ -36,9 +36,9 @@ class Test extends Component {
I am a tooltip}
>
diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx
index 8cb3012..0dd3cf8 100644
--- a/docs/examples/simple.tsx
+++ b/docs/examples/simple.tsx
@@ -88,7 +88,7 @@ class Test extends Component {
});
};
- onVisibleChange = (visible) => {
+ onOpenChange = (visible) => {
console.log('tooltip', visible); // eslint-disable-line no-console
};
@@ -211,7 +211,7 @@ class Test extends Component {
mouseLeaveDelay={0.1}
destroyTooltipOnHide={this.state.destroyTooltipOnHide}
trigger={Object.keys(this.state.trigger) as ActionType[]}
- onVisibleChange={this.onVisibleChange}
+ onOpenChange={this.onOpenChange}
overlay={i am a tooltip
}
align={{
offset: [this.state.offsetX, this.state.offsetY],
diff --git a/src/Tooltip.tsx b/src/Tooltip.tsx
index 5092c6f..061b29b 100644
--- a/src/Tooltip.tsx
+++ b/src/Tooltip.tsx
@@ -23,12 +23,12 @@ export interface TooltipProps
> {
trigger?: ActionType | ActionType[];
defaultVisible?: boolean;
- visible?: boolean;
+ open?: boolean;
placement?: string;
/** Config popup motion */
motion?: TriggerProps['popupMotion'];
- onVisibleChange?: (visible: boolean) => void;
- afterVisibleChange?: (visible: boolean) => void;
+ onOpenChange?: (open: boolean) => void;
+ afterOpenChange?: (open: boolean) => void;
overlay: (() => React.ReactNode) | React.ReactNode;
/** @deprecated Please use `styles={{ root: {} }}` */
overlayStyle?: React.CSSProperties;
@@ -68,8 +68,8 @@ const Tooltip = (props: TooltipProps, ref: React.Ref) => {
overlayStyle,
prefixCls = 'rc-tooltip',
children,
- onVisibleChange,
- afterVisibleChange,
+ onOpenChange,
+ afterOpenChange,
motion,
placement = 'right',
align = {},
@@ -83,6 +83,7 @@ const Tooltip = (props: TooltipProps, ref: React.Ref) => {
showArrow = true,
classNames: tooltipClassNames,
styles: tooltipStyles,
+ open,
...restProps
} = props;
@@ -91,11 +92,6 @@ const Tooltip = (props: TooltipProps, ref: React.Ref) => {
useImperativeHandle(ref, () => triggerRef.current);
- const extraProps: Partial = { ...restProps };
- if ('visible' in props) {
- extraProps.popupVisible = props.visible;
- }
-
const getPopupElement = () => (
) => {
ref={triggerRef}
popupAlign={align}
getPopupContainer={getTooltipContainer}
- onPopupVisibleChange={onVisibleChange}
- afterPopupVisibleChange={afterVisibleChange}
+ onOpenChange={onOpenChange}
+ afterOpenChange={afterOpenChange}
popupMotion={motion}
defaultPopupVisible={defaultVisible}
autoDestroy={destroyTooltipOnHide}
@@ -140,7 +136,8 @@ const Tooltip = (props: TooltipProps, ref: React.Ref) => {
popupStyle={{ ...overlayStyle, ...tooltipStyles?.root }}
mouseEnterDelay={mouseEnterDelay}
arrow={showArrow}
- {...extraProps}
+ popupVisible={open}
+ {...restProps}
>
{getChildren()}
diff --git a/tests/index.test.tsx b/tests/index.test.tsx
index 7436ab8..f52e24a 100644
--- a/tests/index.test.tsx
+++ b/tests/index.test.tsx
@@ -222,7 +222,7 @@ describe('rc-tooltip', () => {
const App = () => {
const [open, setOpen] = React.useState(false);
return (
- Tooltip content} visible={open}>
+ Tooltip content} open={open}>
{
@@ -263,7 +263,7 @@ describe('rc-tooltip', () => {
};
const { container } = render(
- } styles={customStyles} visible>
+ } styles={customStyles} open>
,
);