mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Popover Menu: fix issue hiding menu behind scrollable container (#84311)
* PopoverMenu: change position to fixed * PopoverMenu: close on empty selectionchange * Popover Menu: do not let menu overflow the window dimensions * Prettier
This commit is contained in:
parent
6599fa805d
commit
a89f1c2200
@ -94,7 +94,7 @@ function track(action: string, selectionLength: number, dataSourceType: string |
|
|||||||
|
|
||||||
const getStyles = (theme: GrafanaTheme2) => ({
|
const getStyles = (theme: GrafanaTheme2) => ({
|
||||||
menu: css({
|
menu: css({
|
||||||
position: 'absolute',
|
position: 'fixed',
|
||||||
zIndex: theme.zIndex.modal,
|
zIndex: theme.zIndex.modal,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -121,14 +121,20 @@ class UnThemedLogRows extends PureComponent<Props, State> {
|
|||||||
if (!this.logRowsRef.current) {
|
if (!this.logRowsRef.current) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const parentBounds = this.logRowsRef.current?.getBoundingClientRect();
|
|
||||||
|
const MENU_WIDTH = 270;
|
||||||
|
const MENU_HEIGHT = 105;
|
||||||
|
const x = e.clientX + MENU_WIDTH > window.innerWidth ? window.innerWidth - MENU_WIDTH : e.clientX;
|
||||||
|
const y = e.clientY + MENU_HEIGHT > window.innerHeight ? window.innerHeight - MENU_HEIGHT : e.clientY;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selection,
|
selection,
|
||||||
popoverMenuCoordinates: { x: e.clientX - parentBounds.left, y: e.clientY - parentBounds.top },
|
popoverMenuCoordinates: { x, y },
|
||||||
selectedRow: row,
|
selectedRow: row,
|
||||||
});
|
});
|
||||||
document.addEventListener('click', this.handleDeselection);
|
document.addEventListener('click', this.handleDeselection);
|
||||||
document.addEventListener('contextmenu', this.handleDeselection);
|
document.addEventListener('contextmenu', this.handleDeselection);
|
||||||
|
document.addEventListener('selectionchange', this.handleDeselection);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,6 +153,7 @@ class UnThemedLogRows extends PureComponent<Props, State> {
|
|||||||
closePopoverMenu = () => {
|
closePopoverMenu = () => {
|
||||||
document.removeEventListener('click', this.handleDeselection);
|
document.removeEventListener('click', this.handleDeselection);
|
||||||
document.removeEventListener('contextmenu', this.handleDeselection);
|
document.removeEventListener('contextmenu', this.handleDeselection);
|
||||||
|
document.removeEventListener('selectionchange', this.handleDeselection);
|
||||||
this.setState({
|
this.setState({
|
||||||
selection: '',
|
selection: '',
|
||||||
popoverMenuCoordinates: { x: 0, y: 0 },
|
popoverMenuCoordinates: { x: 0, y: 0 },
|
||||||
|
Loading…
Reference in New Issue
Block a user