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) => ({
|
||||
menu: css({
|
||||
position: 'absolute',
|
||||
position: 'fixed',
|
||||
zIndex: theme.zIndex.modal,
|
||||
}),
|
||||
});
|
||||
|
@ -121,14 +121,20 @@ class UnThemedLogRows extends PureComponent<Props, State> {
|
||||
if (!this.logRowsRef.current) {
|
||||
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({
|
||||
selection,
|
||||
popoverMenuCoordinates: { x: e.clientX - parentBounds.left, y: e.clientY - parentBounds.top },
|
||||
popoverMenuCoordinates: { x, y },
|
||||
selectedRow: row,
|
||||
});
|
||||
document.addEventListener('click', this.handleDeselection);
|
||||
document.addEventListener('contextmenu', this.handleDeselection);
|
||||
document.addEventListener('selectionchange', this.handleDeselection);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -147,6 +153,7 @@ class UnThemedLogRows extends PureComponent<Props, State> {
|
||||
closePopoverMenu = () => {
|
||||
document.removeEventListener('click', this.handleDeselection);
|
||||
document.removeEventListener('contextmenu', this.handleDeselection);
|
||||
document.removeEventListener('selectionchange', this.handleDeselection);
|
||||
this.setState({
|
||||
selection: '',
|
||||
popoverMenuCoordinates: { x: 0, y: 0 },
|
||||
|
Loading…
Reference in New Issue
Block a user