Skip to content

Commit 0285173

Browse files
committed
fix: use default tooltip props for click support on mobile
Signed-off-by: M-DEV-1 <mahadevankizhakkedathu@gmail.com>
1 parent 9bf571a commit 0285173

1 file changed

Lines changed: 4 additions & 24 deletions

File tree

src/custom/CustomTooltip/customTooltip.tsx

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import React, { useMemo, useState } from 'react';
2+
import React from 'react';
33
import { Tooltip, TooltipProps } from '../../base';
44
import { WHITE } from '../../theme';
55
import { RenderMarkdownTooltip } from '../Markdown';
@@ -27,27 +27,10 @@ function CustomTooltip({
2727
componentsProps = {},
2828
...props
2929
}: CustomTooltipProps): JSX.Element {
30-
const [isOpen, setIsOpen] = useState(false);
31-
32-
const isTouchDevice = useMemo(() => {
33-
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
34-
}, []);
35-
36-
const handleTouchStart = (event: React.TouchEvent<HTMLDivElement>) => {
37-
event.preventDefault();
38-
setIsOpen(true);
39-
};
40-
41-
const handleTouchEnd = useMemo(
42-
() =>
43-
_.debounce(() => {
44-
setIsOpen(false);
45-
}, 1500),
46-
[setIsOpen]
47-
);
48-
4930
return (
5031
<Tooltip
32+
enterTouchDelay={0}
33+
leaveTouchDelay={2000}
5134
componentsProps={_.merge(
5235
{
5336
tooltip: {
@@ -76,16 +59,13 @@ function CustomTooltip({
7659
},
7760
componentsProps
7861
)}
79-
open={isTouchDevice ? isOpen : undefined}
8062
title={typeof title === 'string' ? <RenderMarkdownTooltip content={title} /> : title}
8163
placement={placement}
8264
arrow
8365
onClick={onClick}
8466
{...props}
8567
>
86-
<div onTouchStart={handleTouchStart} onTouchEnd={handleTouchEnd}>
87-
{children}
88-
</div>
68+
{children}
8969
</Tooltip>
9070
);
9171
}

0 commit comments

Comments
 (0)