From cfb682c8b93a67415ddb0fce5d59d4ba67e5dd4b Mon Sep 17 00:00:00 2001 From: Ahmed Semih Erkan Date: Wed, 22 May 2024 22:55:28 +0300 Subject: [PATCH] fix(16294): update interface to include target prop in switcheritem type (#16295) Co-authored-by: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com> Co-authored-by: Guilherme Datilio Ribeiro Co-authored-by: Taylor Jones --- .all-contributorsrc | 9 +++++++++ README.md | 1 + .../__snapshots__/PublicAPI-test.js.snap | 3 +++ .../src/components/UIShell/SwitcherItem.tsx | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 7c2332da4168..b98ea9041226 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -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", diff --git a/README.md b/README.md index ee184317aaf8..b46e36d2345f 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
Holly Springsteen

💻
Nikhil Tomar

💻
Anina Antony

💻 +
Ahmed Semih Erkan

💻
Yael Chavoya

💻
Kilian Collender

💻 diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 5e5ec22fae25..8311dbf4bb0c 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -7528,6 +7528,9 @@ Map { "tabIndex": Object { "type": "number", }, + "target": Object { + "type": "string", + }, }, "render": [Function], }, diff --git a/packages/react/src/components/UIShell/SwitcherItem.tsx b/packages/react/src/components/UIShell/SwitcherItem.tsx index 06354fb7151e..b2ebe8e85903 100644 --- a/packages/react/src/components/UIShell/SwitcherItem.tsx +++ b/packages/react/src/components/UIShell/SwitcherItem.tsx @@ -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'; @@ -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 { @@ -80,6 +88,7 @@ const SwitcherItem = forwardRef( handleSwitcherItemFocus, onKeyDown = () => {}, href, + target, ...rest } = props; @@ -122,6 +131,7 @@ const SwitcherItem = forwardRef( onKeyDown(evt); }} href={href} + target={target} ref={forwardRef} {...rest} className={linkClassName} @@ -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;