Skip to content

Commit

Permalink
fix(15510): Update Interface to Include href Prop in SwitcherItem Type (
Browse files Browse the repository at this point in the history
#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 <cardona.n.andrea@gmail.com>
  • Loading branch information
2nikhiltom and andreancardona committed Apr 1, 2024
1 parent 804fb83 commit 599fbf0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Expand Up @@ -7482,6 +7482,9 @@ Map {
"handleSwitcherItemFocus": Object {
"type": "func",
},
"href": Object {
"type": "string",
},
"index": Object {
"type": "number",
},
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/components/UIShell/SwitcherItem.tsx
Expand Up @@ -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 {
Expand Down Expand Up @@ -75,6 +79,7 @@ const SwitcherItem = forwardRef<ElementType, SwitcherItemProps>(
index,
handleSwitcherItemFocus,
onKeyDown = () => {},
href,
...rest
} = props;

Expand Down Expand Up @@ -116,6 +121,7 @@ const SwitcherItem = forwardRef<ElementType, SwitcherItemProps>(
setTabFocus(evt);
onKeyDown(evt);
}}
href={href}
ref={forwardRef}
{...rest}
className={linkClassName}
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 599fbf0

Please sign in to comment.