@@ -718,12 +718,18 @@ const Tooltip = ({
718718 const documentObserverCallback : MutationCallback = ( mutationList ) => {
719719 const addedAnchors = new Set < HTMLElement > ( )
720720 const removedAnchors = new Set < HTMLElement > ( )
721+ const maybeAddAnchor = ( anchor : HTMLElement ) => {
722+ if ( disableTooltip ?.( anchor ) ) {
723+ return
724+ }
725+ addedAnchors . add ( anchor )
726+ }
721727 mutationList . forEach ( ( mutation ) => {
722728 if ( mutation . type === 'attributes' && mutation . attributeName === 'data-tooltip-id' ) {
723729 const target = mutation . target as HTMLElement
724730 const newId = target . getAttribute ( 'data-tooltip-id' )
725731 if ( newId === id ) {
726- addedAnchors . add ( target )
732+ maybeAddAnchor ( target )
727733 } else if ( mutation . oldValue === id ) {
728734 // data-tooltip-id has now been changed, so we need to remove this anchor
729735 removedAnchors . add ( target )
@@ -786,7 +792,7 @@ const Tooltip = ({
786792 const element = node as HTMLElement
787793 if ( element . matches ( selector ) ) {
788794 // the element itself is an anchor
789- addedAnchors . add ( element )
795+ maybeAddAnchor ( element )
790796 } else {
791797 /**
792798 * TODO(V6): do we care if an element which is an anchor,
@@ -796,7 +802,7 @@ const Tooltip = ({
796802 // the element has children which are anchors
797803 element
798804 . querySelectorAll < HTMLElement > ( selector )
799- . forEach ( ( innerNode ) => addedAnchors . add ( innerNode ) )
805+ . forEach ( ( innerNode ) => maybeAddAnchor ( innerNode ) )
800806 }
801807 } )
802808 } catch {
@@ -832,7 +838,15 @@ const Tooltip = ({
832838 clearTimeoutRef ( tooltipHideDelayTimerRef )
833839 clearTimeoutRef ( missedTransitionTimerRef )
834840 }
835- } , [ id , anchorSelect , imperativeOptions ?. anchorSelect , activeAnchor , handleShow , setActiveAnchor ] )
841+ } , [
842+ id ,
843+ anchorSelect ,
844+ imperativeOptions ?. anchorSelect ,
845+ activeAnchor ,
846+ handleShow ,
847+ setActiveAnchor ,
848+ disableTooltip ,
849+ ] )
836850
837851 useEffect ( ( ) => {
838852 updateTooltipPosition ( )
0 commit comments