@@ -8,7 +8,9 @@ import TreeView from 'react-treeview/lib/react-treeview.js';
88import { v1 as uuidv1 } from 'uuid' ;
99
1010const REQUIREMENTS_POPOVER_CLEANUP_KEY = '__tigerpathReqPopoverCleanup' ;
11+ const REQUIREMENTS_POPOVER_CONTENT_KEY = '__tigerpathReqPopoverContent' ;
1112const HEADER_POPOVER_CLEANUP_KEY = '__tigerpathHeaderPopoverCleanup' ;
13+ const HEADER_POPOVER_CONTENT_KEY = '__tigerpathHeaderPopoverContent' ;
1214const TREE_ITEM_CLICK_HANDLER_KEY = '__tigerpathTreeItemClickHandler' ;
1315
1416function escapeHref ( url ) {
@@ -502,7 +504,7 @@ export default function Requirements({ onChange, requirements, schedule, activeP
502504 items . forEach ( ( item ) => {
503505 const existingHandler = item [ TREE_ITEM_CLICK_HANDLER_KEY ] ;
504506 if ( typeof existingHandler === 'function' ) {
505- item . removeEventListener ( 'click' , existingHandler ) ;
507+ return ;
506508 }
507509
508510 const clickHandler = ( event ) => {
@@ -541,7 +543,18 @@ export default function Requirements({ onChange, requirements, schedule, activeP
541543 '.reqLabel:not(.reqLabel-main)'
542544 ) ;
543545 reqLabels . forEach ( ( reqLabel ) => {
546+ const contentSignature = [
547+ reqLabel . getAttribute ( 'reqpath' ) || '' ,
548+ reqLabel . getAttribute ( 'title' ) || '' ,
549+ reqLabel . getAttribute ( 'data-bs-content' ) || '' ,
550+ ] . join ( '|' ) ;
544551 const existingCleanup = reqLabel [ REQUIREMENTS_POPOVER_CLEANUP_KEY ] ;
552+ if (
553+ typeof existingCleanup === 'function' &&
554+ reqLabel [ REQUIREMENTS_POPOVER_CONTENT_KEY ] === contentSignature
555+ ) {
556+ return ;
557+ }
545558 if ( typeof existingCleanup === 'function' ) existingCleanup ( ) ;
546559
547560 const existing = Popover . getInstance ( reqLabel ) ;
@@ -583,7 +596,9 @@ export default function Requirements({ onChange, requirements, schedule, activeP
583596 cleanupHoverBehavior ( ) ;
584597 popoverInstance . dispose ( ) ;
585598 delete reqLabel [ REQUIREMENTS_POPOVER_CLEANUP_KEY ] ;
599+ delete reqLabel [ REQUIREMENTS_POPOVER_CONTENT_KEY ] ;
586600 } ;
601+ reqLabel [ REQUIREMENTS_POPOVER_CONTENT_KEY ] = contentSignature ;
587602 } ) ;
588603 } , [ ] ) ; // eslint-disable-line react-hooks/exhaustive-deps
589604
@@ -594,7 +609,19 @@ export default function Requirements({ onChange, requirements, schedule, activeP
594609
595610 const icons = containerRef . current . querySelectorAll ( '.info-icon' ) ;
596611 icons . forEach ( ( icon ) => {
612+ const contentSignature = [
613+ icon . getAttribute ( 'data-tp-info' ) || '' ,
614+ icon . getAttribute ( 'data-tp-ref0' ) || '' ,
615+ icon . getAttribute ( 'data-tp-ref1' ) || '' ,
616+ icon . getAttribute ( 'data-bs-content' ) || '' ,
617+ ] . join ( '|' ) ;
597618 const existingCleanup = icon [ HEADER_POPOVER_CLEANUP_KEY ] ;
619+ if (
620+ typeof existingCleanup === 'function' &&
621+ icon [ HEADER_POPOVER_CONTENT_KEY ] === contentSignature
622+ ) {
623+ return ;
624+ }
598625 if ( typeof existingCleanup === 'function' ) existingCleanup ( ) ;
599626
600627 const existing = Popover . getInstance ( icon ) ;
@@ -640,7 +667,9 @@ export default function Requirements({ onChange, requirements, schedule, activeP
640667 cleanupHover ( ) ;
641668 popoverInstance . dispose ( ) ;
642669 delete icon [ HEADER_POPOVER_CLEANUP_KEY ] ;
670+ delete icon [ HEADER_POPOVER_CONTENT_KEY ] ;
643671 } ;
672+ icon [ HEADER_POPOVER_CONTENT_KEY ] = contentSignature ;
644673 } ) ;
645674 } , [ ] ) ;
646675
0 commit comments