mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
New Panel Header: Fix when clicking submenu item the parent menu item onClick get's triggered (#65691)
This commit is contained in:
parent
04336d53a9
commit
c03bf7d8ad
@ -2658,7 +2658,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "15"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "15"]
|
||||
],
|
||||
"public/app/features/dashboard/utils/panelMerge.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
|
@ -25,7 +25,7 @@ export const PanelHeaderMenuItem = (props: Props & PanelMenuItem) => {
|
||||
ref={setRef}
|
||||
data-testid={selectors.components.Panels.Panel.menuItems(props.text)}
|
||||
>
|
||||
<a onClick={props.onClick} href={props.href}>
|
||||
<a onClick={props.onClick} href={props.href} role="menuitem">
|
||||
{icon && <Icon name={icon} className={styles.menuIconClassName} />}
|
||||
<span className="dropdown-item-text" aria-label={selectors.components.Panels.Panel.headerItems(props.text)}>
|
||||
{props.text}
|
||||
|
@ -180,7 +180,15 @@ export function getPanelMenu(
|
||||
type: 'submenu',
|
||||
text: t('panel.header-menu.inspect', `Inspect`),
|
||||
iconClassName: 'info-circle',
|
||||
onClick: (e: React.MouseEvent<any>) => onInspectPanel(),
|
||||
onClick: (e: React.MouseEvent<HTMLElement>) => {
|
||||
const currentTarget = e.currentTarget;
|
||||
const target = e.target as HTMLElement;
|
||||
const closestMenuItem = target.closest('[role="menuitem"]');
|
||||
|
||||
if (target === currentTarget || closestMenuItem === currentTarget) {
|
||||
onInspectPanel();
|
||||
}
|
||||
},
|
||||
shortcut: 'i',
|
||||
subMenu: inspectMenu,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user