Skip to content

Commit 867d6ba

Browse files
committed
Update docs
1 parent 58982ef commit 867d6ba

File tree

2 files changed

+58
-26
lines changed

2 files changed

+58
-26
lines changed

packages/eui/src/components/flyout/flyout_menu.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface EuiFlyoutHistoryItem {
4747
}
4848

4949
/**
50-
* Custom action item for the flyout menu header
50+
* Custom action item for the flyout menu component
5151
*/
5252
export interface EuiFlyoutMenuCustomAction {
5353
/**
@@ -75,32 +75,29 @@ export type EuiFlyoutMenuProps = CommonProps &
7575
* ```jsx
7676
* <EuiFlyout
7777
* aria-labelledby="myMenuTitleId"
78+
* flyoutMenuProps={{ title: 'Menu title', titleId: 'myMenuTitleId' }
7879
* >
79-
* <EuiFlyoutMenu
80-
* titleId="myMenuTitleId"
81-
* title="Menu title"
82-
* />
80+
* ...
8381
* </EuiFlyout>
8482
* ```
8583
*/
8684
titleId?: string;
8785
/**
88-
* Title for the menu header
86+
* Title for the menu component. In a managed flyout context, the title is used to indicate the flyout session for history navigation.
8987
*/
9088
title?: React.ReactNode;
9189
/**
92-
* Hides the title in the flyout menu bar.
93-
* If the flyout is used in a managed flyout session as a "main" flyout, the default will be true, as main flyouts typically show a title in an EuiFlyoutHeader instead.
94-
* @default true for main flyout in managed flyout session; false otherwise
90+
* Hides the title in the `EuiFlyoutMenu`. This is useful when the title is already shown in an `EuiFlyoutHeader`.
91+
* @default true for main flyout in a managed flyout session; false otherwise
9592
*/
9693
hideTitle?: boolean;
9794
/**
98-
* Hides the close button in the menu header
95+
* Hides the close button in the menu component
9996
* @default false
10097
*/
10198
hideCloseButton?: boolean;
10299
/**
103-
* Shows a back button in the menu header
100+
* Shows a back button in the menu component
104101
* @default false
105102
*/
106103
showBackButton?: boolean;
@@ -113,7 +110,7 @@ export type EuiFlyoutMenuProps = CommonProps &
113110
*/
114111
historyItems?: EuiFlyoutHistoryItem[];
115112
/**
116-
* List of custom action items for the menu header
113+
* List of custom action items for the menu component
117114
*/
118115
customActions?: EuiFlyoutMenuCustomAction[];
119116
};

packages/website/docs/components/containers/flyout/session-management.mdx

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ export default () => {
3939
<EuiFlyout
4040
session="start"
4141
size="s"
42-
aria-label="Flyout A - main"
43-
flyoutMenuProps={{
44-
title: 'Welcome to the flyout session management journey!',
45-
}}
42+
aria-labelledby="welcomeHeading"
43+
flyoutMenuProps={{ title: 'Flyout A' }}
4644
onClose={() => setIsOpenFlyoutA(false)}
4745
>
46+
<EuiFlyoutHeader>
47+
<EuiTitle>
48+
<h2 id="welcomeHeading">
49+
Welcome to the flyout session management journey!
50+
</h2>
51+
</EuiTitle>
52+
</EuiFlyoutHeader>
4853
<EuiFlyoutBody>
4954
<EuiText>This flyout is rendered with the <EuiCode>{'session="start"'}</EuiCode> prop set which creates a new flyout session and marks this flyout as main.</EuiText>
5055
<EuiSpacer />
@@ -60,12 +65,17 @@ export default () => {
6065
<EuiFlyout
6166
session="start"
6267
size="m"
63-
aria-label="Flyout B - main"
64-
flyoutMenuProps={{
65-
title: <>Glad to meet you, {name || 'stranger'}!</>,
66-
}}
68+
aria-labelledby="flyoutBHeading"
69+
flyoutMenuProps={{ title: 'Flyout B' }}
6770
onClose={() => setIsOpenFlyoutB(false)}
6871
>
72+
<EuiFlyoutHeader>
73+
<EuiTitle>
74+
<h2 id="flyoutBHeading">
75+
Glad to meet you, {name || 'stranger'}!
76+
</h2>
77+
</EuiTitle>
78+
</EuiFlyoutHeader>
6979
<EuiFlyoutBody>
7080
<EuiText>
7181
This flyout is also rendered with the <EuiCode>{'session="start"'}</EuiCode> prop added which creates a <strong>second flyout session</strong> and marks this flyout as main in that session.
@@ -78,7 +88,11 @@ export default () => {
7888
</EuiButton>
7989
</EuiFlyoutBody>
8090
{isOpenFlyoutBChild && (
81-
<EuiFlyout size="s" aria-label="Flyout B - child" onClose={() => setIsOpenFlyoutBChild(false)}>
91+
<EuiFlyout
92+
size="s"
93+
aria-label="Child of Flyout B"
94+
onClose={() => setIsOpenFlyoutBChild(false)}
95+
>
8296
<EuiFlyoutBody>
8397
<EuiText>
8498
This is a <strong>child flyout</strong> of Flyout B. It belongs to the same session as Flyout B because it's rendered inside of it and doesn't have the <EuiCode>session</EuiCode> prop set.
@@ -119,9 +133,19 @@ All bindings and configuration will be handled automatically.
119133

120134
### Session title
121135

122-
Flyout sessions within the managed system require a title that can be
123-
referenced in the history navigation features. Use the `title`
124-
field of the `flyoutMenuProps` to set the title of the flyout.
136+
Managed flyout sessions require a title that can be referenced in the history
137+
navigation features. Use the `title` field of the `flyoutMenuProps` to set the
138+
title of the flyout session. If `flyoutMenuProps` is omitted or a `title` field
139+
is not given in `flyoutMenuProps`, the manager will use the `aria-label`
140+
attribute of `EuiFlyout` as the source for the session's title. If no source
141+
for a title is given, a default title will be provided.
142+
143+
:::info Note
144+
The "main" flyout in a session should use `EuiFlyoutHeader` for the actual
145+
flyout heading. For this reason, the `title` given from `flyoutMenuProps` will
146+
not be visible to end users. However, a title is still needed for the history
147+
navigation feature of the flyout session management system.
148+
:::
125149

126150
```tsx
127151
{/* Render a new main flyout and create a flyout session */}
@@ -130,17 +154,28 @@ field of the `flyoutMenuProps` to set the title of the flyout.
130154
flyoutMenuProps={{
131155
title: 'My main flyout'
132156
}}
157+
aria-labelledby="myFlyoutHeading"
133158
>
159+
<EuiFlyoutHeader>
160+
<EuiTitle>
161+
<h2 id="myFlyoutHeading">
162+
I'm the main flyout heading
163+
</h2>
164+
</EuiTitle>
165+
</EuiFlyoutHeader>
134166
<EuiFlyoutBody>
135-
I'm the main flyout
167+
I'm the main flyout body
136168
</EuiFlyoutBody>
137169
{/* Render a new child flyout - notice the lack of the `session` prop */}
138170
<EuiFlyout
139171
flyoutMenuProps={{
140172
title: 'My child flyout'
141173
}}
142174
>
143-
I'm the child flyout that belongs to the same session as the main flyout
175+
{/* Render a child flyout contents. Notice the lack of the EuiFlyoutHeader component - the child flyout menu shows the title from flyoutMenuProps */}
176+
<EuiFlyoutBody>
177+
I'm the child flyout that belongs to the same session as the main flyout
178+
</EuiFlyoutBody>
144179
</EuiFlyout>
145180
</EuiFlyout>
146181
```

0 commit comments

Comments
 (0)