Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-aria-components/src/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const Breadcrumb = /*#__PURE__*/ createLeafComponent(
let isCurrent = node.nextKey == null;
let {isDisabled, onAction} = useSlottedContext(BreadcrumbsContext)!;
let linkProps = {
'aria-current': isCurrent ? 'page' : null,
'aria-current': isCurrent ? ('page' as const) : undefined,
isDisabled: isDisabled || isCurrent,
onPress: () => onAction?.(node.key)
};
Expand Down
2 changes: 1 addition & 1 deletion packages/react-aria-components/src/NavigationTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ function NavigationTreeItemContentInner(props: NavigationTreeItemContentInnerPro
// Provide onFocusChange so the link reports its focus up to NavigationTreeItem.
let linkContextValue = {
...linkProps,
'aria-current': isCurrent ? 'page' : undefined,
'aria-current': isCurrent ? ('page' as const) : undefined,
onFocusChange: setLinkFocused,
onPress: linkProps.href == null && hasChildItems ? () => state.toggleKey(id) : undefined
};
Expand Down
6 changes: 6 additions & 0 deletions packages/react-aria-components/test/Link.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ describe('Link', () => {
expect(link).toHaveAttribute('id', 'my-link-id');
});

it('should support accessibility props', () => {
let {getByRole} = render(<Link aria-current="page">Test</Link>);
let link = getByRole('link');
expect(link).toHaveAttribute('aria-current', 'page');
});

it('should support render props', async () => {
let {getByRole} = render(<Link>{({isHovered}) => (isHovered ? 'Hovered' : 'Test')}</Link>);
let link = getByRole('link');
Expand Down
8 changes: 7 additions & 1 deletion packages/react-aria/src/link/useLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ import {usePress} from '../interactions/usePress';

export interface LinkProps extends PressEvents, FocusableProps {}

export interface AriaLinkProps extends LinkProps, LinkDOMProps, AriaLabelingProps {}
export interface AriaLinkProps extends LinkProps, LinkDOMProps, AriaLabelingProps {
/**
* Indicates whether this element represents the current item within a container or set of related
* elements.
*/
'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time';
}

export interface AriaLinkOptions extends AriaLinkProps {
/** Whether the link is disabled. */
Expand Down