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:
Jack Westbrook 2024-08-27 12:28:48 +02:00 committed by GitHub
parent 5a30e12a10
commit c0a719caa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,7 @@ export interface WithContextMenuProps {
export const WithContextMenu = ({ children, renderMenuItems, focusOnOpen = true }: WithContextMenuProps) => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 });
const isBodyScrolling = window.grafanaBootData?.settings.featureToggles.bodyScrolling;
return (
<>
{children({
@ -22,7 +23,7 @@ export const WithContextMenu = ({ children, renderMenuItems, focusOnOpen = true
setIsMenuOpen(true);
setMenuPosition({
x: e.pageX,
y: e.pageY,
y: isBodyScrolling ? e.pageY - window.scrollY : e.pageY,
});
},
})}

View File

@ -27,6 +27,7 @@ global.$ = global.jQuery = $;
// mock the default window.grafanaBootData settings
const settings: Partial<GrafanaBootConfig> = {
angularSupportEnabled: true,
featureToggles: {},
};
global.grafanaBootData = {
settings,