File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import _ from 'lodash' ;
2- import React from 'react' ;
2+ import React , { useState } from 'react' ;
33import { Tooltip , TooltipProps } from '../../base' ;
44import { WHITE } from '../../theme' ;
55import { RenderMarkdownTooltip } from '../Markdown' ;
@@ -27,6 +27,21 @@ function CustomTooltip({
2727 componentsProps = { } ,
2828 ...props
2929} : CustomTooltipProps ) : JSX . Element {
30+ const [ isOpen , setIsOpen ] = useState ( false ) ;
31+
32+ const isTouchDevice = ( ) => {
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 = ( ) => {
42+ setTimeout ( ( ) => setIsOpen ( false ) , 1500 ) ;
43+ } ;
44+
3045 return (
3146 < Tooltip
3247 componentsProps = { _ . merge (
@@ -57,13 +72,16 @@ function CustomTooltip({
5772 } ,
5873 componentsProps
5974 ) }
75+ open = { isTouchDevice ( ) ? isOpen : undefined }
6076 title = { typeof title === 'string' ? < RenderMarkdownTooltip content = { title } /> : title }
6177 placement = { placement }
6278 arrow
6379 onClick = { onClick }
6480 { ...props }
6581 >
66- { children }
82+ < div onTouchStart = { handleTouchStart } onTouchEnd = { handleTouchEnd } >
83+ { children }
84+ </ div >
6785 </ Tooltip >
6886 ) ;
6987}
You can’t perform that action at this time.
0 commit comments