File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,20 @@ const TargetSvgContainer = styled.g`
1515 cursor: ${ props => ( props . mode === 'hover' ? 'default' : 'pointer' ) } ;
1616` ;
1717
18+ const isDescendantOfAction = element => {
19+ const { parentElement } = element ;
20+
21+ if ( parentElement . tagName === 'BODY' ) {
22+ return false ;
23+ }
24+
25+ if ( parentElement . tagName === 'A' || parentElement . tagName === 'BUTTON' ) {
26+ return true ;
27+ }
28+
29+ return isDescendantOfAction ( parentElement ) ;
30+ } ;
31+
1832function WithTooltip ( {
1933 svg,
2034 trigger,
@@ -30,8 +44,8 @@ function WithTooltip({
3044 const Container = svg ? TargetSvgContainer : TargetContainer ;
3145 const [ isTooltipShown , setTooltipShown ] = useState ( startOpen ) ;
3246 const toggleTooltipShown = ( ) => setTooltipShown ( ! isTooltipShown ) ;
33- const closeTooltipOnClick = ( ) => {
34- if ( ! closeOnClick ) {
47+ const closeTooltipOnClick = event => {
48+ if ( ! closeOnClick || ! isDescendantOfAction ( event . target ) ) {
3549 return ;
3650 }
3751
You can’t perform that action at this time.
0 commit comments