grafana/public/app/core/services/withFocusedPanelId.ts
Torkel Ödegaard feaaa32ffd
Shortcuts: Fixes panel shortcuts so they always work (#32385)
* Shortcuts: Fixes panel shortcuts so they always work

* Updated snapshot
2021-03-29 07:52:57 +02:00

13 lines
368 B
TypeScript

export function withFocusedPanel(fn: (panelId: number) => void) {
return () => {
const elements = document.querySelectorAll(':hover');
for (let i = elements.length - 1; i > 0; i--) {
const element = (elements[i] as unknown) as HTMLElement;
if (element.dataset?.panelid) {
fn(parseInt(element.dataset?.panelid, 10));
}
}
};
}