From e4d0a3e5739531aabf4482838848b4f110426126 Mon Sep 17 00:00:00 2001 From: Aryan Bagade Date: Mon, 15 Dec 2025 13:20:57 -0800 Subject: [PATCH] fix(react-aria-components): add id prop to Link component The Link component was missing the `id` prop in its TypeScript interface, even though it worked at runtime via filterDOMProps. This adds DOMProps to LinkProps interface to expose the id prop, matching the pattern used by other components like OverlayArrow and FieldError Fixes #9348 --- packages/react-aria-components/src/Link.tsx | 4 ++-- packages/react-aria-components/test/Link.test.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-aria-components/src/Link.tsx b/packages/react-aria-components/src/Link.tsx index 22df63e3ac3..35f0667c727 100644 --- a/packages/react-aria-components/src/Link.tsx +++ b/packages/react-aria-components/src/Link.tsx @@ -19,11 +19,11 @@ import { useContextProps, useRenderProps } from './utils'; +import {DOMProps, forwardRefType, GlobalDOMAttributes} from '@react-types/shared'; import {filterDOMProps} from '@react-aria/utils'; -import {forwardRefType, GlobalDOMAttributes} from '@react-types/shared'; import React, {createContext, ElementType, ForwardedRef, forwardRef} from 'react'; -export interface LinkProps extends Omit, HoverEvents, RenderProps, SlotProps, Omit, 'onClick'> { +export interface LinkProps extends Omit, HoverEvents, RenderProps, SlotProps, DOMProps, Omit, 'onClick'> { /** * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. * @default 'react-aria-Link' diff --git a/packages/react-aria-components/test/Link.test.js b/packages/react-aria-components/test/Link.test.js index d2defeabf52..3b34d8dd1ff 100644 --- a/packages/react-aria-components/test/Link.test.js +++ b/packages/react-aria-components/test/Link.test.js @@ -40,6 +40,12 @@ describe('Link', () => { expect(link).toHaveAttribute('data-foo', 'bar'); }); + it('should support id prop', () => { + let {getByRole} = render(Test); + let link = getByRole('link'); + expect(link).toHaveAttribute('id', 'my-link-id'); + }); + it('should support render props', async () => { let {getByRole} = render({({isHovered}) => isHovered ? 'Hovered' : 'Test'}); let link = getByRole('link');