mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datalinks: Fix context menu position for body scroll (#92389)
* fix(datalinks): position context menu offest to vertical window scroll * feature toggle change * enhance boot data mock with empty featureToggles --------- Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
parent
5a30e12a10
commit
c0a719caa7
@ -15,6 +15,7 @@ export interface WithContextMenuProps {
|
|||||||
export const WithContextMenu = ({ children, renderMenuItems, focusOnOpen = true }: WithContextMenuProps) => {
|
export const WithContextMenu = ({ children, renderMenuItems, focusOnOpen = true }: WithContextMenuProps) => {
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||||
const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 });
|
const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 });
|
||||||
|
const isBodyScrolling = window.grafanaBootData?.settings.featureToggles.bodyScrolling;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{children({
|
{children({
|
||||||
@ -22,7 +23,7 @@ export const WithContextMenu = ({ children, renderMenuItems, focusOnOpen = true
|
|||||||
setIsMenuOpen(true);
|
setIsMenuOpen(true);
|
||||||
setMenuPosition({
|
setMenuPosition({
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: isBodyScrolling ? e.pageY - window.scrollY : e.pageY,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
|
@ -27,6 +27,7 @@ global.$ = global.jQuery = $;
|
|||||||
// mock the default window.grafanaBootData settings
|
// mock the default window.grafanaBootData settings
|
||||||
const settings: Partial<GrafanaBootConfig> = {
|
const settings: Partial<GrafanaBootConfig> = {
|
||||||
angularSupportEnabled: true,
|
angularSupportEnabled: true,
|
||||||
|
featureToggles: {},
|
||||||
};
|
};
|
||||||
global.grafanaBootData = {
|
global.grafanaBootData = {
|
||||||
settings,
|
settings,
|
||||||
|
Loading…
Reference in New Issue
Block a user