diff --git a/.all-contributorsrc b/.all-contributorsrc
index 0b8113115af6..7d58177cff28 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -1397,6 +1397,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "amercury",
+ "name": "Alexandr Ovchinnikov",
+ "avatar_url": "https://avatars.githubusercontent.com/u/17834588?v=4",
+ "profile": "https://github.com/amercury",
+ "contributions": [
+ "code"
+ ]
}
],
"commitConvention": "none"
diff --git a/README.md b/README.md
index ddc01897ed09..3636d7c35e58 100644
--- a/README.md
+++ b/README.md
@@ -271,6 +271,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
SamChinellato 💻 |
stevenpatrick009 💻 |
HunterXalc 💻 |
+ Alexandr Ovchinnikov 💻 |
Matias Borghi 💻 |
diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
index ed212e4292e5..8b4192c9b5f6 100644
--- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
+++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
@@ -7379,6 +7379,9 @@ Map {
"index": Object {
"type": "number",
},
+ "onClick": Object {
+ "type": "func",
+ },
"onKeyDown": Object {
"type": "func",
},
diff --git a/packages/react/src/components/UIShell/SwitcherItem.tsx b/packages/react/src/components/UIShell/SwitcherItem.tsx
index 0f4af096f6c9..90f303c73ade 100644
--- a/packages/react/src/components/UIShell/SwitcherItem.tsx
+++ b/packages/react/src/components/UIShell/SwitcherItem.tsx
@@ -30,6 +30,10 @@ interface BaseSwitcherItemProps {
* event handlers
*/
onKeyDown?: (event: KeyboardEvent) => void;
+ /**
+ * event handlers
+ */
+ onClick?: (event: MouseEvent) => void;
/**
* Specify the tab index of the Link
*/
@@ -143,6 +147,10 @@ SwitcherItem.propTypes = {
* Specify the index of the SwitcherItem
*/
index: PropTypes.number,
+ /**
+ * event handlers
+ */
+ onClick: PropTypes.func,
/**
* event handlers
*/
diff --git a/packages/react/src/components/UIShell/__tests__/SwitcherItem-test.js b/packages/react/src/components/UIShell/__tests__/SwitcherItem-test.js
index 45599f0bbe80..dd1b8d35e884 100644
--- a/packages/react/src/components/UIShell/__tests__/SwitcherItem-test.js
+++ b/packages/react/src/components/UIShell/__tests__/SwitcherItem-test.js
@@ -7,7 +7,7 @@
import React from 'react';
import SwitcherItem from '../SwitcherItem';
-import { render, screen } from '@testing-library/react';
+import { render, screen, fireEvent } from '@testing-library/react';
describe('SwitcherItem', () => {
describe('renders as expected - Component API', () => {
@@ -78,5 +78,19 @@ describe('SwitcherItem', () => {
'-1'
);
});
+
+ it('should handle onClick event', () => {
+ const dummyHandler = jest.fn();
+
+ render(
+
+ Dummy child
+
+ );
+
+ fireEvent.click(screen.getByRole('listitem').firstChild);
+
+ expect(dummyHandler).toHaveBeenCalledTimes(1);
+ });
});
});