From 599fbf0e82602943da7e48450ca8b0f9a9d59b51 Mon Sep 17 00:00:00 2001 From: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com> Date: Mon, 1 Apr 2024 21:58:38 +0530 Subject: [PATCH] fix(15510): Update Interface to Include href Prop in SwitcherItem Type (#16043) * fix(15510): update switcherItem interface * Update SwitcherItem.tsx * fix(15510): update propType and href passed to Link * chore(15510): fix typo * chore: update snaps --------- Co-authored-by: Andrea N. Cardona --- .../__tests__/__snapshots__/PublicAPI-test.js.snap | 3 +++ packages/react/src/components/UIShell/SwitcherItem.tsx | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 262754c98087..9eaeaf9a64fa 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -7482,6 +7482,9 @@ Map { "handleSwitcherItemFocus": Object { "type": "func", }, + "href": Object { + "type": "string", + }, "index": Object { "type": "number", }, diff --git a/packages/react/src/components/UIShell/SwitcherItem.tsx b/packages/react/src/components/UIShell/SwitcherItem.tsx index 90f303c73ade..06354fb7151e 100644 --- a/packages/react/src/components/UIShell/SwitcherItem.tsx +++ b/packages/react/src/components/UIShell/SwitcherItem.tsx @@ -46,6 +46,10 @@ interface BaseSwitcherItemProps { * Specify whether the panel is selected */ isSelected?: boolean; + /** + * Optionally provide an href for the underlying li` + */ + href?: string; } interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps { @@ -75,6 +79,7 @@ const SwitcherItem = forwardRef( index, handleSwitcherItemFocus, onKeyDown = () => {}, + href, ...rest } = props; @@ -116,6 +121,7 @@ const SwitcherItem = forwardRef( setTabFocus(evt); onKeyDown(evt); }} + href={href} ref={forwardRef} {...rest} className={linkClassName} @@ -143,6 +149,10 @@ SwitcherItem.propTypes = { * event handlers */ handleSwitcherItemFocus: PropTypes.func, + /** + * Optionally provide an href for the underlying li` + */ + href: PropTypes.string, /** * Specify the index of the SwitcherItem */