mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SingleTopNav: Fix org switcher in overlayed MegaMenu (#95654)
fix org switcher in singleTopNav
This commit is contained in:
parent
d77fc50198
commit
b42c34070a
@ -882,6 +882,9 @@ export const versionedComponents = {
|
||||
},
|
||||
},
|
||||
Select: {
|
||||
menu: {
|
||||
'11.4.0': 'data-testid Select menu',
|
||||
},
|
||||
option: {
|
||||
'11.1.0': 'data-testid Select option',
|
||||
[MIN_GRAFANA_VERSION]: 'Select option',
|
||||
|
@ -47,7 +47,13 @@ export const SelectMenu = ({
|
||||
const optionsElement = components?.Option ?? SelectMenuOptions;
|
||||
|
||||
return (
|
||||
<div {...innerProps} className={styles.menu} style={{ maxHeight }} aria-label="Select options menu">
|
||||
<div
|
||||
{...innerProps}
|
||||
data-testid={selectors.components.Select.menu}
|
||||
className={styles.menu}
|
||||
style={{ maxHeight }}
|
||||
aria-label="Select options menu"
|
||||
>
|
||||
<CustomScrollbar scrollRefCallback={innerRef} autoHide={false} autoHeightMax="inherit" hideHorizontalTrack>
|
||||
{toggleAllOptions && (
|
||||
<ToggleAllOption
|
||||
|
@ -6,6 +6,7 @@ import { useRef } from 'react';
|
||||
import CSSTransition from 'react-transition-group/CSSTransition';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { useStyles2, useTheme2 } from '@grafana/ui';
|
||||
import { useGrafana } from 'app/core/context/GrafanaContext';
|
||||
@ -40,7 +41,12 @@ export function AppChromeMenu({}: Props) {
|
||||
// don't close when clicking on the menu toggle, let the toggle button handle that
|
||||
// this prevents some nasty flickering when the menu is open and the toggle button is clicked
|
||||
const isMenuToggle = document.getElementById(TOGGLE_BUTTON_ID)?.contains(element);
|
||||
return !isMenuToggle;
|
||||
// don't close when interacting with a select menu inside the mega menu
|
||||
// e.g. for the org switcher
|
||||
const isSelectMenu = document
|
||||
.querySelector(`[data-testid=${selectors.components.Select.menu}]`)
|
||||
?.contains(element);
|
||||
return !isMenuToggle && !isSelectMenu;
|
||||
},
|
||||
},
|
||||
ref
|
||||
|
Loading…
Reference in New Issue
Block a user