From b2f561a22b2843769af637c58fcaeec360f4b7f0 Mon Sep 17 00:00:00 2001 From: Reid Barber Date: Mon, 20 May 2024 12:44:41 -0500 Subject: [PATCH] Revert "feat(RAC Breadcrumbs): add autoFocusCurrent to RAC Breadcrumbs (#6325)" (#6407) This reverts commit 122d0c87a7a9a07336bc5859719b35d6ee67dd82. --- .../react-aria-components/src/Breadcrumbs.tsx | 32 ++++++---------- .../stories/Breadcrumbs.stories.tsx | 38 ------------------- .../test/Breadcrumbs.test.js | 13 ------- 3 files changed, 12 insertions(+), 71 deletions(-) delete mode 100644 packages/react-aria-components/stories/Breadcrumbs.stories.tsx diff --git a/packages/react-aria-components/src/Breadcrumbs.tsx b/packages/react-aria-components/src/Breadcrumbs.tsx index e6deafd0c98..91e5557c710 100644 --- a/packages/react-aria-components/src/Breadcrumbs.tsx +++ b/packages/react-aria-components/src/Breadcrumbs.tsx @@ -22,9 +22,7 @@ export interface BreadcrumbsProps extends Omit, '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, HTMLOListElement>>(null); @@ -56,18 +54,14 @@ function BreadcrumbsInner({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 ( - - ); - })} + {[...collection].map((node, i) => ( + + ))} ); } @@ -99,17 +93,15 @@ interface BreadcrumbItemProps { node: Node, 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 ( diff --git a/packages/react-aria-components/stories/Breadcrumbs.stories.tsx b/packages/react-aria-components/stories/Breadcrumbs.stories.tsx deleted file mode 100644 index a8a1d8aa344..00000000000 --- a/packages/react-aria-components/stories/Breadcrumbs.stories.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 Adobe. All rights reserved. - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -import {Breadcrumb, Breadcrumbs, Link} from 'react-aria-components'; -import React from 'react'; - -export default { - title: 'React Aria Components', - component: Breadcrumbs, - argTypes: { - autoFocusCurrent: { - control: {type: 'boolean'} - } - } -}; - -export const BreadcrumbsExample = (args: any) => ( - - - Home - - - React Aria - - - Breadcrumbs - - -); diff --git a/packages/react-aria-components/test/Breadcrumbs.test.js b/packages/react-aria-components/test/Breadcrumbs.test.js index 906c7b8ad28..61515cacd76 100644 --- a/packages/react-aria-components/test/Breadcrumbs.test.js +++ b/packages/react-aria-components/test/Breadcrumbs.test.js @@ -103,17 +103,4 @@ describe('Breadcrumbs', () => { let item = getByRole('listitem'); expect(breadcrumbRef.current).toBe(item); }); - - it('should support autoFocusCurrent', () => { - let {getAllByRole} = render( - - Home - React Aria - useBreadcrumbs - - ); - - let links = getAllByRole('link'); - expect(links[2]).toHaveFocus(); - }); });