@@ -17,7 +17,7 @@ import {
1717 getMatchedStylesWithBlankRule ,
1818} from '../../testing/StyleHelpers.js' ;
1919import * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js' ;
20- import type * as Tooltips from '../../ui/components/tooltips/tooltips.js' ;
20+ import * as Tooltips from '../../ui/components/tooltips/tooltips.js' ;
2121import * as InlineEditor from '../../ui/legacy/components/inline_editor/inline_editor.js' ;
2222import * as LegacyUI from '../../ui/legacy/legacy.js' ;
2323
@@ -675,11 +675,12 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
675675 const cssVarSwatch = linkSwatch . parentElement ;
676676 assert . exists ( cssVarSwatch ) ;
677677 assert . exists ( stylePropertyTreeElement . valueElement ) ;
678- renderElementIntoDOM ( stylePropertyTreeElement . valueElement , { allowMultipleChildren : true } ) ;
678+ renderElementIntoDOM ( stylePropertyTreeElement . valueElement ) ;
679679
680680 assert . strictEqual ( stylePropertyTreeElement . valueElement . innerText , `var(${ varName } , var(--blue))` ) ;
681681 assert . strictEqual ( linkSwatch ?. innerText , varName ) ;
682682 assert . strictEqual ( cssVarSwatch . innerText , `var(${ varName } , var(--blue))` ) ;
683+ stylePropertyTreeElement . valueElement . remove ( ) ;
683684 }
684685 } ) ;
685686
@@ -1437,7 +1438,7 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
14371438 const swatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-color-swatch' ) ;
14381439 assert . exists ( swatch ) ;
14391440 assert . exists ( stylePropertyTreeElement . valueElement ) ;
1440- renderElementIntoDOM ( stylePropertyTreeElement . valueElement , { allowMultipleChildren : true } ) ;
1441+ renderElementIntoDOM ( stylePropertyTreeElement . valueElement ) ;
14411442 assert . strictEqual ( swatch ?. innerText , lightDark ) ;
14421443 const activeColor = colorScheme === SDK . CSSModel . ColorScheme . LIGHT ? lightText : darkText ;
14431444 assert . strictEqual (
@@ -1449,6 +1450,7 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
14491450 const inactive = colorScheme === SDK . CSSModel . ColorScheme . LIGHT ? dark : light ;
14501451 assert . isTrue ( inactive . parentElement ?. classList . contains ( 'inactive-value' ) ) ;
14511452 assert . isFalse ( active . parentElement ?. classList . contains ( 'inactive-value' ) ) ;
1453+ stylePropertyTreeElement . valueElement . remove ( ) ;
14521454 }
14531455
14541456 await check ( SDK . CSSModel . ColorScheme . LIGHT , 'red' , 'blue' ) ;
@@ -1694,11 +1696,12 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
16941696 const stylePropertyTreeElement = getTreeElement ( 'width' , property ) ;
16951697 stylePropertyTreeElement . updateTitle ( ) ;
16961698 assert . exists ( stylePropertyTreeElement . valueElement ) ;
1697- renderElementIntoDOM ( stylePropertyTreeElement . valueElement , { allowMultipleChildren : true } ) ;
1699+ renderElementIntoDOM ( stylePropertyTreeElement . valueElement ) ;
16981700 const tooltip = stylePropertyTreeElement . valueElement . querySelector ( 'devtools-tooltip' ) ;
16991701 assert . exists ( tooltip ) ;
17001702 const widget = tooltip . firstElementChild && LegacyUI . Widget . Widget . get ( tooltip . firstElementChild ) ;
17011703 assert . instanceOf ( widget , Elements . CSSValueTraceView . CSSValueTraceView ) ;
1704+ stylePropertyTreeElement . valueElement . remove ( ) ;
17021705 }
17031706 } ) ;
17041707
@@ -1819,4 +1822,25 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
18191822 ] ) ;
18201823 } ) ;
18211824 } ) ;
1825+
1826+ it ( 'reopens open tooltips on updates' , async ( ) => {
1827+ const openTooltipStub = sinon . stub ( Tooltips . Tooltip . Tooltip . prototype , 'showPopover' ) ;
1828+ const openTooltipPromise1 = new Promise < void > ( r => openTooltipStub . callsFake ( r ) ) ;
1829+ const stylePropertyTreeElement = getTreeElement ( 'color' , 'color-mix(in srgb, red, blue)' ) ;
1830+ stylePropertyTreeElement . updateTitle ( ) ;
1831+ const tooltip = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-tooltip' ) ;
1832+ assert . exists ( tooltip ) ;
1833+ renderElementIntoDOM ( tooltip ) ;
1834+ tooltip . showTooltip ( ) ;
1835+ await openTooltipPromise1 ;
1836+ tooltip . remove ( ) ;
1837+
1838+ const openTooltipPromise2 = new Promise < void > ( r => openTooltipStub . callsFake ( r ) ) ;
1839+ stylePropertyTreeElement . updateTitle ( ) ;
1840+ const tooltip2 = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-tooltip' ) ;
1841+ assert . exists ( tooltip2 ) ;
1842+ renderElementIntoDOM ( tooltip2 ) ;
1843+ await openTooltipPromise2 ;
1844+ assert . notStrictEqual ( tooltip , tooltip2 ) ;
1845+ } ) ;
18221846} ) ;
0 commit comments