Skip to content

Commit 85881fc

Browse files
authoredApr 15, 2022
fix(Tooltip):修复被禁用时任然可能触发弹层问题 #772 (#773)
1 parent 305541d commit 85881fc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎packages/react-overlay-trigger/src/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ export default React.forwardRef<OverlayTriggerRef, OverlayTriggerProps>((props,
198198
hoverStateRef.current = 'show';
199199

200200
const delay = normalizeDelay(props.delay);
201-
202-
if (!delay.show) {
201+
if (!delay.show && !(props.children as JSX.Element)?.props.disabled) {
203202
show();
204203
return;
205204
}
206205
const handle = window.setTimeout(() => {
207206
if (hoverStateRef.current === 'show') show();
208207
}, delay.show);
208+
clearTimeout(handle);
209209
timeoutRef.current.push(handle);
210210
}
211211

‎packages/react-tooltip/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const Demo = () => (
3636
<Tooltip placement="bottom" content="下边文字提示">
3737
<Button>下边文字提示(bottom)</Button>
3838
</Tooltip>
39+
<Tooltip placement="top" content="已被禁用">
40+
<Button disabled={true}>禁用</Button>
41+
</Tooltip>
3942
</div>
4043
)
4144
ReactDOM.render(<Demo />, _mount_);

0 commit comments

Comments
 (0)
Please sign in to comment.