Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(15510): Update Interface to Include href Prop in SwitcherItem Type #16043

Merged
merged 11 commits into from
Apr 1, 2024
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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