mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
ToolbarButtonRow: prevent closure of overflow menu when interacting with portal elements (#68319)
* don't close the overflow menu when interacting with something in a portal * keep overflow ref logic
This commit is contained in:
@@ -7,6 +7,7 @@ import React, { forwardRef, HTMLAttributes, useState, useRef, useLayoutEffect, c
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
|
||||
import { useTheme2 } from '../../themes';
|
||||
import { getPortalContainer } from '../Portal/Portal';
|
||||
|
||||
import { ToolbarButton } from './ToolbarButton';
|
||||
export interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||
@@ -29,7 +30,10 @@ export const ToolbarButtonRow = forwardRef<HTMLDivElement, Props>(
|
||||
onClose: () => setShowOverflowItems(false),
|
||||
isDismissable: true,
|
||||
isOpen: showOverflowItems,
|
||||
shouldCloseOnInteractOutside: (element: Element) => !overflowRef.current?.contains(element),
|
||||
shouldCloseOnInteractOutside: (element: Element) => {
|
||||
const portalContainer = getPortalContainer();
|
||||
return !overflowRef.current?.contains(element) && !portalContainer.contains(element);
|
||||
},
|
||||
},
|
||||
overflowItemsRef
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user