Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('builds navigation tree', () => {
children: [
{
...panelOpenerNode,
href: '/foo/bar', // Panel opener with a link should not be converted to accordion
href: '/foo/bar', // Panel opener with a link should also be converted to accordion when side nav is collapsed
},
],
},
Expand All @@ -220,7 +220,7 @@ describe('builds navigation tree', () => {

const accordionButtonLabel = queryAllByTestId('accordionToggleBtn').map((c) => c.textContent);

expect(accordionButtonLabel).toEqual(['Group 1']); // Only 1 accordion button (top level)
expect(accordionButtonLabel).toEqual(['Group 1', 'Nested Group 1']);
unmount();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const getRenderAs = (
navNode: ChromeProjectNavigationNode,
{ isSideNavCollapsed }: { isSideNavCollapsed: boolean }
): RenderAs => {
if (isSideNavCollapsed && navNode.renderAs === 'panelOpener' && !nodeHasLink(navNode))
return 'accordion'; // When the side nav is collapsed, we render panel openers as accordions if they don't have a landing page
if (isSideNavCollapsed && navNode.renderAs === 'panelOpener') return 'accordion'; // When the side nav is collapsed, we render panel openers as accordions
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix

if (navNode.renderAs) return navNode.renderAs;
if (!navNode.children) return 'item';
return DEFAULT_RENDER_AS;
Expand Down Expand Up @@ -108,7 +107,7 @@ const getTestSubj = (navNode: ChromeProjectNavigationNode, isActive = false): st
});
};

const serializeNavNode = (
export const serializeNavNode = (
navNode: ChromeProjectNavigationNode,
{
isSideNavCollapsed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import {
EuiPanel,
EuiWindowEvent,
keys,
useEuiTheme,
} from '@elastic/eui';
import React, { useCallback, type FC } from 'react';
import classNames from 'classnames';

import type { PanelSelectedNode } from '@kbn/core-chrome-browser';
import { usePanel } from './context';
import { getNavPanelStyles, getPanelWrapperStyles } from './styles';
import { navPanelStyles, panelWrapperStyles } from './styles';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I thought the bug was caused by styling, so I cleaned up styles in this component to use @emotion/react instead of @emotion/css.


const getTestSubj = (selectedNode: PanelSelectedNode | null): string | undefined => {
if (!selectedNode) return;
Expand All @@ -33,7 +32,6 @@ const getTestSubj = (selectedNode: PanelSelectedNode | null): string | undefined
};

export const NavigationPanel: FC = () => {
const { euiTheme } = useEuiTheme();
const { isOpen, close, getContent, selectedNode, selectedNodeEl } = usePanel();

// ESC key closes PanelNav
Expand Down Expand Up @@ -68,22 +66,21 @@ export const NavigationPanel: FC = () => {
[close, selectedNodeEl]
);

const panelWrapperClasses = getPanelWrapperStyles();
const sideNavPanelStyles = getNavPanelStyles(euiTheme);
const panelClasses = classNames('sideNavPanel', 'eui-yScroll', sideNavPanelStyles);

if (!isOpen) {
return null;
}

const panelClasses = classNames('sideNavPanel', 'eui-yScroll');

return (
<>
<EuiWindowEvent event="keydown" handler={onKeyDown} />
<div className={panelWrapperClasses}>
<EuiFocusTrap autoFocus css={{ height: '100%' }}>
<div css={panelWrapperStyles}>
<EuiFocusTrap autoFocus style={{ height: '100%' }}>
<EuiOutsideClickDetector onOutsideClick={onOutsideClick}>
<EuiPanel
className={panelClasses}
css={navPanelStyles}
hasShadow
borderRadius="none"
paddingSize="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { type EuiThemeComputed } from '@elastic/eui';
import { css } from '@emotion/css';
import { Theme, css } from '@emotion/react';

const PANEL_WIDTH = '248px';

export const getPanelWrapperStyles = () => css`
export const panelWrapperStyles = css`
clip-path: polygon(
0 0,
150% 0,
Expand All @@ -25,7 +24,7 @@ export const getPanelWrapperStyles = () => css`
top: 0;
`;

export const getNavPanelStyles = (euiTheme: EuiThemeComputed<{}>) => css`
export const navPanelStyles = ({ euiTheme }: Theme) => css`
background-color: ${euiTheme.colors.backgroundBaseSubdued};
height: 100%;
width: ${PANEL_WIDTH};
Expand Down