From 33c018fcad876fe0503d93fec3f8b09dec88aade Mon Sep 17 00:00:00 2001 From: Josh Black Date: Thu, 25 Jun 2026 09:33:05 -0500 Subject: [PATCH] feat: add React Compiler support for Tooltip Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .changeset/react-compiler-tooltip-v2.md | 5 +++ packages/react/script/react-compiler.mjs | 1 - .../src/TooltipV2/__tests__/Tooltip.test.tsx | 35 +++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 .changeset/react-compiler-tooltip-v2.md diff --git a/.changeset/react-compiler-tooltip-v2.md b/.changeset/react-compiler-tooltip-v2.md new file mode 100644 index 00000000000..9181f409f21 --- /dev/null +++ b/.changeset/react-compiler-tooltip-v2.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +Tooltip: Improve rendering performance with React Compiler support diff --git a/packages/react/script/react-compiler.mjs b/packages/react/script/react-compiler.mjs index 184c468cfc0..4198b0a6a24 100644 --- a/packages/react/script/react-compiler.mjs +++ b/packages/react/script/react-compiler.mjs @@ -40,7 +40,6 @@ const unsupportedPatterns = [ 'src/hooks/useScrollFlash.ts', 'src/internal/components/CheckboxOrRadioGroup/**/*.tsx', 'src/hooks/useMergedRefs.ts', - 'src/TooltipV2/**/*.tsx', ] const unsupported = new Set( diff --git a/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx b/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx index c87f32e59a5..6ee91eb38b6 100644 --- a/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx +++ b/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx @@ -29,8 +29,11 @@ const TooltipComponentWithExistingDescription = (props: Omit ) -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function ExampleWithActionMenu(actionMenuTrigger: React.ReactElement): JSX.Element { +interface ExampleWithActionMenuProps { + actionMenuTrigger: React.ReactElement +} + +function ExampleWithActionMenu({actionMenuTrigger}: ExampleWithActionMenuProps): JSX.Element { return ( @@ -82,11 +85,13 @@ describe('Tooltip', () => { it('should spread the accessibility attributes correctly on the trigger (ActionMenu.Button) when tooltip is used in an action menu', () => { const {getByRole, getByText} = HTMLRender( - ExampleWithActionMenu( - - Toggle Menu - , - ), + + Toggle Menu + + } + />, ) const menuButton = getByRole('button') const tooltip = getByText('Additional context about the menu button') @@ -96,13 +101,15 @@ describe('Tooltip', () => { it('should spread the accessibility attributes correctly on the trigger (Button) when tooltip is used in an action menu', () => { const {getByRole, getByText} = HTMLRender( - ExampleWithActionMenu( - - - - - , - ), + + + + + + } + />, ) const menuButton = getByRole('button') const tooltip = getByText('Additional context about the menu button')