mirror of https://github.com/grafana/grafana
Navigation: Prevent chevron overlaying navbar menus (#47988)
* Attach nav item menus to a portal that's a sibling of the chevron to prevent incorrect stacking * Make sure hover menus size correctly * refactor into separate component * Fix focus behaviour * fix test again...pull/48045/head
parent
28665a869b
commit
11bc5e1a06
@ -0,0 +1,26 @@ |
||||
import React from 'react'; |
||||
import { css } from '@emotion/css'; |
||||
import { GrafanaTheme2 } from '@grafana/data'; |
||||
import { useTheme2 } from '@grafana/ui'; |
||||
|
||||
const NAV_MENU_PORTAL_CONTAINER_ID = 'navbar-menu-portal-container'; |
||||
|
||||
export const getNavMenuPortalContainer = () => document.getElementById(NAV_MENU_PORTAL_CONTAINER_ID) ?? document.body; |
||||
|
||||
export const NavBarMenuPortalContainer = () => { |
||||
const theme = useTheme2(); |
||||
const styles = getStyles(theme); |
||||
return <div className={styles.menuPortalContainer} id={NAV_MENU_PORTAL_CONTAINER_ID} />; |
||||
}; |
||||
|
||||
NavBarMenuPortalContainer.displayName = 'NavBarMenuPortalContainer'; |
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({ |
||||
menuPortalContainer: css({ |
||||
left: 0, |
||||
position: 'fixed', |
||||
right: 0, |
||||
top: 0, |
||||
zIndex: theme.zIndex.sidemenu, |
||||
}), |
||||
}); |
Loading…
Reference in new issue