@@ -82,8 +82,12 @@ function ExampleWithTooltip(): JSX.Element {
8282 )
8383}
8484
85- // eslint-disable-next-line @typescript-eslint/no-explicit-any
86- function ExampleWithTooltipV2 ( actionMenuTrigger : React . ReactElement < any > ) : JSX . Element {
85+ function ExampleWithTooltipV2 ( {
86+ actionMenuTrigger,
87+ } : {
88+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89+ actionMenuTrigger : React . ReactElement < any >
90+ } ) : JSX . Element {
8791 return (
8892 < BaseStyles >
8993 < ActionMenu >
@@ -99,6 +103,8 @@ function ExampleWithTooltipV2(actionMenuTrigger: React.ReactElement<any>): JSX.E
99103}
100104
101105function ExampleWithReplaceableAnchor ( ) : JSX . Element {
106+ 'use no memo'
107+
102108 const anchorRef = useRef < HTMLButtonElement > ( null )
103109 const [ open , setOpen ] = useState ( false )
104110 const [ anchorKey , setAnchorKey ] = useState ( 0 )
@@ -392,11 +398,13 @@ describe('ActionMenu', () => {
392398
393399 it ( 'should open menu on menu button click and it is wrapped with tooltip v2' , async ( ) => {
394400 const component = HTMLRender (
395- ExampleWithTooltipV2 (
396- < TooltipV2 text = "Additional context about the menu button" direction = "s" >
397- < ActionMenu . Button > Toggle Menu</ ActionMenu . Button >
398- </ TooltipV2 > ,
399- ) ,
401+ < ExampleWithTooltipV2
402+ actionMenuTrigger = {
403+ < TooltipV2 text = "Additional context about the menu button" direction = "s" >
404+ < ActionMenu . Button > Toggle Menu</ ActionMenu . Button >
405+ </ TooltipV2 >
406+ }
407+ /> ,
400408 )
401409 const button = component . getByRole ( 'button' )
402410
@@ -415,11 +423,13 @@ describe('ActionMenu', () => {
415423
416424 it ( 'should display tooltip v2 when menu button is focused' , async ( ) => {
417425 const component = HTMLRender (
418- ExampleWithTooltipV2 (
419- < TooltipV2 text = "Additional context about the menu button" direction = "s" >
420- < ActionMenu . Button > Toggle Menu</ ActionMenu . Button >
421- </ TooltipV2 > ,
422- ) ,
426+ < ExampleWithTooltipV2
427+ actionMenuTrigger = {
428+ < TooltipV2 text = "Additional context about the menu button" direction = "s" >
429+ < ActionMenu . Button > Toggle Menu</ ActionMenu . Button >
430+ </ TooltipV2 >
431+ }
432+ /> ,
423433 )
424434 const button = component . getByRole ( 'button' )
425435 act ( ( ) => {
@@ -431,13 +441,15 @@ describe('ActionMenu', () => {
431441
432442 it ( 'should open menu on menu anchor click and it is wrapped with tooltip v2' , async ( ) => {
433443 const component = HTMLRender (
434- ExampleWithTooltipV2 (
435- < ActionMenu . Anchor >
436- < TooltipV2 text = "Additional context about the menu button" direction = "n" >
437- < Button > Toggle Menu</ Button >
438- </ TooltipV2 >
439- </ ActionMenu . Anchor > ,
440- ) ,
444+ < ExampleWithTooltipV2
445+ actionMenuTrigger = {
446+ < ActionMenu . Anchor >
447+ < TooltipV2 text = "Additional context about the menu button" direction = "n" >
448+ < Button > Toggle Menu</ Button >
449+ </ TooltipV2 >
450+ </ ActionMenu . Anchor >
451+ }
452+ /> ,
441453 )
442454 const button = component . getByRole ( 'button' )
443455
@@ -449,13 +461,15 @@ describe('ActionMenu', () => {
449461
450462 it ( 'should display tooltip v2 and menu anchor is focused' , async ( ) => {
451463 const component = HTMLRender (
452- ExampleWithTooltipV2 (
453- < ActionMenu . Anchor >
454- < TooltipV2 text = "Additional context about the menu button" direction = "n" >
455- < Button > Toggle Menu</ Button >
456- </ TooltipV2 >
457- </ ActionMenu . Anchor > ,
458- ) ,
464+ < ExampleWithTooltipV2
465+ actionMenuTrigger = {
466+ < ActionMenu . Anchor >
467+ < TooltipV2 text = "Additional context about the menu button" direction = "n" >
468+ < Button > Toggle Menu</ Button >
469+ </ TooltipV2 >
470+ </ ActionMenu . Anchor >
471+ }
472+ /> ,
459473 )
460474 const button = component . getByRole ( 'button' )
461475 act ( ( ) => {
@@ -805,11 +819,15 @@ describe('ActionMenu', () => {
805819
806820 const newAnchor = component . getByRole ( 'button' , { name : 'Open menu' } )
807821 expect ( newAnchor ) . not . toBe ( initialAnchor )
822+ const newOverlay = component . baseElement . querySelector ( '[data-component="ActionMenu.Overlay"]' ) as HTMLElement
823+ expect ( newOverlay ) . not . toBeNull ( )
808824
809825 // The new anchor should have the same anchor-name re-applied, and the
810826 // overlay should still reference it via position-anchor.
811- expect ( newAnchor . style . getPropertyValue ( 'anchor-name' ) ) . toBe ( initialAnchorName )
812- expect ( overlay . style . getPropertyValue ( 'position-anchor' ) ) . toBe ( initialPositionAnchor )
827+ await waitFor ( ( ) => {
828+ expect ( newAnchor . style . getPropertyValue ( 'anchor-name' ) ) . toBe ( initialAnchorName )
829+ expect ( newOverlay . style . getPropertyValue ( 'position-anchor' ) ) . toBe ( initialPositionAnchor )
830+ } )
813831 } )
814832 } )
815833
0 commit comments