mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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.", "12"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
[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.", "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": [
|
"public/app/features/dashboard/utils/panelMerge.ts:5381": [
|
||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||||
|
@ -25,7 +25,7 @@ export const PanelHeaderMenuItem = (props: Props & PanelMenuItem) => {
|
|||||||
ref={setRef}
|
ref={setRef}
|
||||||
data-testid={selectors.components.Panels.Panel.menuItems(props.text)}
|
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} />}
|
{icon && <Icon name={icon} className={styles.menuIconClassName} />}
|
||||||
<span className="dropdown-item-text" aria-label={selectors.components.Panels.Panel.headerItems(props.text)}>
|
<span className="dropdown-item-text" aria-label={selectors.components.Panels.Panel.headerItems(props.text)}>
|
||||||
{props.text}
|
{props.text}
|
||||||
|
@ -180,7 +180,15 @@ export function getPanelMenu(
|
|||||||
type: 'submenu',
|
type: 'submenu',
|
||||||
text: t('panel.header-menu.inspect', `Inspect`),
|
text: t('panel.header-menu.inspect', `Inspect`),
|
||||||
iconClassName: 'info-circle',
|
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',
|
shortcut: 'i',
|
||||||
subMenu: inspectMenu,
|
subMenu: inspectMenu,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user