diff --git a/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx b/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx index d448e9c8efd..cc106c22ad0 100644 --- a/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx +++ b/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState, useLayoutEffect, useCallback } from 'react'; +import React, { useRef, useState, useLayoutEffect } from 'react'; import { selectors } from '@grafana/e2e-selectors'; import { useClickAway } from 'react-use'; import { Portal } from '../Portal/Portal'; @@ -47,12 +47,6 @@ export const ContextMenu: React.FC = React.memo(({ x, y, onClo } }); - const onClick = useCallback(() => { - if (onClose) { - onClose(); - } - }, [onClose]); - const header = renderHeader && renderHeader(); return ( @@ -61,6 +55,7 @@ export const ContextMenu: React.FC = React.memo(({ x, y, onClo ref={menuRef} style={positionStyles} ariaLabel={selectors.components.Menu.MenuComponent('Context')} + onClick={onClose} > {itemsGroup?.map((group, index) => ( @@ -73,7 +68,7 @@ export const ContextMenu: React.FC = React.memo(({ x, y, onClo target={item.target} icon={item.icon} active={item.active} - onClick={onClick} + onClick={item.onClick} /> ))} diff --git a/public/app/features/panel/panellinks/link_srv.ts b/public/app/features/panel/panellinks/link_srv.ts index 7b4d94430bb..5541e9b2542 100644 --- a/public/app/features/panel/panellinks/link_srv.ts +++ b/public/app/features/panel/panellinks/link_srv.ts @@ -324,7 +324,7 @@ export class LinkSrv implements LinkService { const info: LinkModel = { href: locationUtil.assureBaseUrl(href.replace(/\n/g, '')), title: replaceVariables ? replaceVariables(link.title || '') : link.title, - target: link.targetBlank ? '_blank' : '_self', + target: link.targetBlank ? '_blank' : undefined, origin, onClick, };