Skip to content

Commit

Permalink
fix(Tooltip):修复被禁用时任然可能触发弹层问题 #772 (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr-z committed Apr 15, 2022
1 parent 305541d commit 85881fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react-overlay-trigger/src/index.tsx
Expand Up @@ -198,14 +198,14 @@ export default React.forwardRef<OverlayTriggerRef, OverlayTriggerProps>((props,
hoverStateRef.current = 'show';

const delay = normalizeDelay(props.delay);

if (!delay.show) {
if (!delay.show && !(props.children as JSX.Element)?.props.disabled) {
show();
return;
}
const handle = window.setTimeout(() => {
if (hoverStateRef.current === 'show') show();
}, delay.show);
clearTimeout(handle);
timeoutRef.current.push(handle);
}

Expand Down
3 changes: 3 additions & 0 deletions packages/react-tooltip/README.md
Expand Up @@ -36,6 +36,9 @@ const Demo = () => (
<Tooltip placement="bottom" content="下边文字提示">
<Button>下边文字提示(bottom)</Button>
</Tooltip>
<Tooltip placement="top" content="已被禁用">
<Button disabled={true}>禁用</Button>
</Tooltip>
</div>
)
ReactDOM.render(<Demo />, _mount_);
Expand Down

0 comments on commit 85881fc

Please sign in to comment.