Skip to content

Commit 4cabc3b

Browse files
fix(global-header): close help dropdown when selecting Quick Start menu item (#2981)
Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com>
1 parent 6657354 commit 4cabc3b

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-global-header': patch
3+
---
4+
5+
Fix help dropdown not closing when selecting Quick Start menu item.

workspaces/global-header/plugins/global-header/src/components/HeaderDropdownComponent/HelpDropdown.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { useEffect, useMemo, useRef } from 'react';
1818
import type { ComponentType, CSSProperties } from 'react';
19+
import type { MenuItemProps } from '@mui/material/MenuItem';
1920
import { HeaderDropdownComponent } from './HeaderDropdownComponent';
2021
import { useDropdownManager } from '../../hooks';
2122
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
@@ -25,6 +26,7 @@ import { DropdownEmptyState } from './DropdownEmptyState';
2526
import SupportAgentIcon from '@mui/icons-material/SupportAgent';
2627
import { useValidComponentTracker } from '../../hooks/useValidComponentTracker';
2728
import { useTranslation } from '../../hooks/useTranslation';
29+
import type { MenuItemLinkProps } from '../MenuItemLink/MenuItemLink';
2830

2931
/**
3032
* @public
@@ -102,14 +104,17 @@ export const HelpDropdown = ({ layout }: HelpDropdownProps) => {
102104

103105
return {
104106
componentId,
105-
Component: () => (
106-
<ValidityTracker
107-
Component={mp.Component}
108-
props={mp.config?.props || {}}
109-
componentId={componentId}
110-
onValidityChange={updateComponentValidity}
111-
/>
112-
),
107+
Component: (props: MenuItemLinkProps | MenuItemProps | {}) => {
108+
const onClick = 'onClick' in props ? props.onClick : undefined;
109+
return (
110+
<ValidityTracker
111+
Component={mp.Component}
112+
props={{ ...(mp.config?.props || {}), onClick }}
113+
componentId={componentId}
114+
onValidityChange={updateComponentValidity}
115+
/>
116+
);
117+
},
113118
icon: mp.config?.props?.icon,
114119
label: mp.config?.props?.title,
115120
link: mp.config?.props?.link,

0 commit comments

Comments
 (0)