mirror of
https://github.com/grafana/grafana.git
synced 2025-01-13 09:32:12 -06:00
GraphContextMenu: Fixes add annotation action & data links that cause full page reload (#31915)
* GraphContextMenu: Fixes add annotation action * Fixed issue with data links causing full page reload * A better solution to closing context menu
This commit is contained in:
parent
34105a6db8
commit
82e9d59121
@ -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<ContextMenuProps> = React.memo(({ x, y, onClo
|
||||
}
|
||||
});
|
||||
|
||||
const onClick = useCallback(() => {
|
||||
if (onClose) {
|
||||
onClose();
|
||||
}
|
||||
}, [onClose]);
|
||||
|
||||
const header = renderHeader && renderHeader();
|
||||
return (
|
||||
<Portal>
|
||||
@ -61,6 +55,7 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.memo(({ x, y, onClo
|
||||
ref={menuRef}
|
||||
style={positionStyles}
|
||||
ariaLabel={selectors.components.Menu.MenuComponent('Context')}
|
||||
onClick={onClose}
|
||||
>
|
||||
{itemsGroup?.map((group, index) => (
|
||||
<MenuGroup key={`${group.label}${index}`} label={group.label} ariaLabel={group.label}>
|
||||
@ -73,7 +68,7 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.memo(({ x, y, onClo
|
||||
target={item.target}
|
||||
icon={item.icon}
|
||||
active={item.active}
|
||||
onClick={onClick}
|
||||
onClick={item.onClick}
|
||||
/>
|
||||
))}
|
||||
</MenuGroup>
|
||||
|
@ -324,7 +324,7 @@ export class LinkSrv implements LinkService {
|
||||
const info: LinkModel<T> = {
|
||||
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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user