Skip to content

Commit

Permalink
fix(16294): update interface to include target prop in switcheritem t…
Browse files Browse the repository at this point in the history
…ype (#16295)

Co-authored-by: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com>
Co-authored-by: Guilherme Datilio Ribeiro <guilhermedatilio@gmail.com>
Co-authored-by: Taylor Jones <taylor.jones826@gmail.com>
  • Loading branch information
4 people authored May 22, 2024
1 parent db816e6 commit cfb682c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,15 @@
]
},
{
"login": "ahmedsemih",
"name": "Ahmed Semih Erkan",
"avatar_url": "https://avatars.githubusercontent.com/u/102798814?v=4",
"profile": "https://github.com/ahmedsemih",
"contributions": [
"code"
]
},
{
"login": "ychavoya",
"name": "Yael Chavoya",
"avatar_url": "https://avatars.githubusercontent.com/u/7907338?v=4",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
<td align="center"><a href="https://hollyos.com/"><img src="https://avatars.githubusercontent.com/u/4097509?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Holly Springsteen</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=hollyos" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/2nikhiltom"><img src="https://avatars.githubusercontent.com/2nikhiltom?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikhil Tomar</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=2nikhiltom" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/aninaantony"><img src="https://avatars.githubusercontent.com/u/164350784?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anina Antony</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=aninaantony" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ahmedsemih"><img src="https://avatars.githubusercontent.com/u/102798814?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ahmed Semih Erkan</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=ahmedsemih" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ychavoya"><img src="https://avatars.githubusercontent.com/u/7907338?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yael Chavoya</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=ychavoya" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Kilian-Collender"><img src="https://avatars.githubusercontent.com/u/37899503?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kilian Collender</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=Kilian-Collender" title="Code">💻</a></td>
</tr>
Expand Down
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7528,6 +7528,9 @@ Map {
"tabIndex": Object {
"type": "number",
},
"target": Object {
"type": "string",
},
},
"render": [Function],
},
Expand Down
16 changes: 15 additions & 1 deletion packages/react/src/components/UIShell/SwitcherItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, { ElementType, forwardRef } from 'react';
import React, {
ElementType,
forwardRef,
HTMLAttributeAnchorTarget,
} from 'react';
import cx from 'classnames';
import PropTypes from 'prop-types';
import Link from './Link';
Expand Down Expand Up @@ -50,6 +54,10 @@ interface BaseSwitcherItemProps {
* Optionally provide an href for the underlying li`
*/
href?: string;
/**
* Specify where to open the link.
*/
target?: HTMLAttributeAnchorTarget;
}

interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps {
Expand Down Expand Up @@ -80,6 +88,7 @@ const SwitcherItem = forwardRef<ElementType, SwitcherItemProps>(
handleSwitcherItemFocus,
onKeyDown = () => {},
href,
target,
...rest
} = props;

Expand Down Expand Up @@ -122,6 +131,7 @@ const SwitcherItem = forwardRef<ElementType, SwitcherItemProps>(
onKeyDown(evt);
}}
href={href}
target={target}
ref={forwardRef}
{...rest}
className={linkClassName}
Expand Down Expand Up @@ -169,6 +179,10 @@ SwitcherItem.propTypes = {
* Specify the tab index of the Link
*/
tabIndex: PropTypes.number,
/**
* Specify where to open the link.
*/
target: PropTypes.string,
};

export default SwitcherItem;

0 comments on commit cfb682c

Please sign in to comment.