Skip to content

Commit

Permalink
Revert "feat(RAC Breadcrumbs): add autoFocusCurrent to RAC Breadcrumbs (
Browse files Browse the repository at this point in the history
#6325)" (#6407)

This reverts commit 122d0c8.
  • Loading branch information
reidbarber authored May 20, 2024
1 parent d80999e commit b2f561a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 71 deletions.
32 changes: 12 additions & 20 deletions packages/react-aria-components/src/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export interface BreadcrumbsProps<T> extends Omit<CollectionProps<T>, 'disabledK
/** Whether the breadcrumbs are disabled. */
isDisabled?: boolean,
/** Handler that is called when a breadcrumb is clicked. */
onAction?: (key: Key) => void,
/** Whether to autoFocus the last Breadcrumb item when the Breadcrumbs render. */
autoFocusCurrent?: boolean
onAction?: (key: Key) => void
}

export const BreadcrumbsContext = createContext<ContextValue<BreadcrumbsProps<any>, HTMLOListElement>>(null);
Expand Down Expand Up @@ -56,18 +54,14 @@ function BreadcrumbsInner<T extends object>({props, collection, breadcrumbsRef:
slot={props.slot || undefined}
style={props.style}
className={props.className ?? 'react-aria-Breadcrumbs'}>
{[...collection].map((node, i) => {
let isCurrent = i === collection.size - 1;
return (
<BreadcrumbItem
key={node.key}
node={node}
isCurrent={isCurrent}
isDisabled={props.isDisabled}
onAction={props.onAction}
autoFocus={props.autoFocusCurrent && isCurrent} />
);
})}
{[...collection].map((node, i) => (
<BreadcrumbItem
key={node.key}
node={node}
isCurrent={i === collection.size - 1}
isDisabled={props.isDisabled}
onAction={props.onAction} />
))}
</ol>
);
}
Expand Down Expand Up @@ -99,17 +93,15 @@ interface BreadcrumbItemProps {
node: Node<object>,
isCurrent: boolean,
isDisabled?: boolean,
onAction?: (key: Key) => void,
autoFocus?: boolean
onAction?: (key: Key) => void
}

function BreadcrumbItem({node, isCurrent, isDisabled, onAction, autoFocus}: BreadcrumbItemProps) {
function BreadcrumbItem({node, isCurrent, isDisabled, onAction}: BreadcrumbItemProps) {
// Recreating useBreadcrumbItem because we want to use composition instead of having the link builtin.
let linkProps = {
'aria-current': isCurrent ? 'page' : null,
isDisabled: isDisabled || isCurrent,
onPress: () => onAction?.(node.key),
autoFocus: autoFocus
onPress: () => onAction?.(node.key)
};

return (
Expand Down
38 changes: 0 additions & 38 deletions packages/react-aria-components/stories/Breadcrumbs.stories.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions packages/react-aria-components/test/Breadcrumbs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,4 @@ describe('Breadcrumbs', () => {
let item = getByRole('listitem');
expect(breadcrumbRef.current).toBe(item);
});

it('should support autoFocusCurrent', () => {
let {getAllByRole} = render(
<Breadcrumbs autoFocusCurrent>
<Breadcrumb><Link href="/">Home</Link></Breadcrumb>
<Breadcrumb><Link href="/react-aria">React Aria</Link></Breadcrumb>
<Breadcrumb><Link href="/react-aria">useBreadcrumbs</Link></Breadcrumb>
</Breadcrumbs>
);

let links = getAllByRole('link');
expect(links[2]).toHaveFocus();
});
});

0 comments on commit b2f561a

Please sign in to comment.