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
15 changes: 14 additions & 1 deletion packages/eui/src/components/flyout/flyout.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,15 @@ export const EuiFlyoutComponent = forwardRef(
return _titleId || generatedMenuId;
}, [hasMenu, _titleId, generatedMenuId]);

// If the flyout level is LEVEL_MAIN, the title should be hidden by default
const flyoutMenuHideTitle = useMemo(() => {
if (!hasMenu) return undefined;
if (_flyoutMenuProps?.hideTitle !== undefined) {
return _flyoutMenuProps.hideTitle;
}
return currentSession?.mainFlyoutId === flyoutId;
}, [hasMenu, _flyoutMenuProps, currentSession, flyoutId]);

const ariaLabelledBy = useMemo(() => {
if (flyoutMenuId) {
return classnames(flyoutMenuId, _ariaLabelledBy);
Expand Down Expand Up @@ -700,7 +709,11 @@ export const EuiFlyoutComponent = forwardRef(
/>
)}
{_flyoutMenuProps && (
<EuiFlyoutMenu {...flyoutMenuProps} titleId={flyoutMenuId} />
<EuiFlyoutMenu
{...flyoutMenuProps}
hideTitle={flyoutMenuHideTitle}
titleId={flyoutMenuId}
/>
)}
{resizable && (
<EuiFlyoutResizeButton
Expand Down
16 changes: 16 additions & 0 deletions packages/eui/src/components/flyout/flyout_menu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { EuiText } from '../text';
import { EuiFlyout } from './flyout';
import { EuiFlyoutBody } from './flyout_body';
import { EuiFlyoutMenu, EuiFlyoutMenuProps } from './flyout_menu';
import { EuiFlyoutHeader } from './flyout_header';

interface Args extends EuiFlyoutMenuProps {
showCustomActions: boolean;
Expand All @@ -26,6 +27,7 @@ const meta: Meta<Args> = {
title: 'Layout/EuiFlyout/EuiFlyoutMenu',
component: EuiFlyoutMenu,
argTypes: {
hideTitle: { control: 'boolean' },
showBackButton: { control: 'boolean' },
showCustomActions: { control: 'boolean' },
'aria-label': { table: { disable: true } },
Expand All @@ -38,13 +40,15 @@ const meta: Meta<Args> = {
showBackButton: true,
showCustomActions: true,
showHistoryItems: true,
hideTitle: true,
},
};

export default meta;

const MenuBarFlyout = (args: Args) => {
const {
hideTitle,
hideCloseButton,
showBackButton,
showCustomActions,
Expand Down Expand Up @@ -80,6 +84,8 @@ const MenuBarFlyout = (args: Args) => {
'aria-label': `${iconType} action`,
}));

const titleId = 'menu-bar-example-main-title';

return (
<>
<EuiButton onClick={openFlyout} disabled={isFlyoutOpen}>
Expand All @@ -94,15 +100,25 @@ const MenuBarFlyout = (args: Args) => {
type="overlay"
outsideClickCloses={false}
ownFocus
aria-labelledby={titleId}
flyoutMenuProps={{
title: 'Flyout title',
titleId,
hideTitle,
hideCloseButton,
showBackButton,
backButtonProps,
historyItems,
customActions: showCustomActions ? customActions : undefined,
}}
>
{hideTitle && (
<EuiFlyoutHeader hasBorder>
<EuiText>
<h2 id={titleId}>Simple flyout header</h2>
</EuiText>
</EuiFlyoutHeader>
)}
<EuiFlyoutBody>
<EuiText>
<p>Simple flyout content.</p>
Expand Down
4 changes: 4 additions & 0 deletions packages/eui/src/components/flyout/flyout_menu.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { css } from '@emotion/react';
import { UseEuiTheme } from '../../services';
import { euiScreenReaderOnly } from '../accessibility';

export const euiFlyoutMenuStyles = (euiThemeContext: UseEuiTheme) => {
const { euiTheme } = euiThemeContext;
Expand All @@ -31,5 +32,8 @@ export const euiFlyoutMenuStyles = (euiThemeContext: UseEuiTheme) => {
euiFlyoutMenu__actions: css`
block-size: calc(${euiTheme.size.m} * 1.8);
`,
euiFlyoutMenu__hiddenTitle: css`
${euiScreenReaderOnly()}
`,
};
};
Loading