[Flyout System] Add flyout menu display modes#9426
Conversation
6e03cd9 to
5f55d2a
Compare
There was a problem hiding this comment.
I tested only EUI Storybook. Thank you for the detailed testing checklist 🙏🏻 Code looks alright, everything works as expected. I only found a couple of nits and have 2 questions.
EDIT:
One more thing I noticed, I think there are a couple of test cases missing.
use_flyout_menu.test.ts:
describe('flyoutMenuHideTitle', () => {
it('returns true when flyout is the main flyout in session', () => {});
it('returns false when flyout is not the main flyout', () => {});
it('returns true when explicit hideTitle is true', () => {});
it('returns false when explicit hideTitle is false even for main flyout', () => {});
});
describe('shouldRenderMenu with display modes', () => {
describe('always mode', () => {
it('returns true even when menu has no content', () => {});
});
describe('auto mode', () => {
it('returns true when menu has back button', () => {});
it('returns true when menu has history items', () => {});
it('returns true when menu has custom actions', () => {});
it('returns true when menu has visible title', () => {});
it('returns false when menu has no content', () => {});
it('returns false when menu only has a hidden title', () => {});
});
});
describe('ariaLabelledBy', () => {
it('includes flyoutMenuId when menu is rendered', () => {});
it('combines flyoutMenuId with existing ariaLabelledBy', () => {});
it('excludes flyoutMenuId when auto mode hides the menu', () => {});
});flyout.test.tsx:
describe('flyoutMenuDisplayMode', () => {
describe('always mode', () => {
it('renders menu even when menu has no content', () => {});
});
describe('auto mode', () => {
it('renders menu when menu has content', () => {});
it('renders close button when menu has no content', () => {});
it('renders no close button when hideCloseButton is true and menu has no content', () => {});
});
describe('aria-labelledby', () => {
it('includes menu titleId when menu is rendered', () => {});
it('excludes menu titleId when auto mode hides the menu', () => {});
});
});| {shouldRenderMenu ? ( | ||
| <EuiFlyoutMenu | ||
| {...flyoutMenuProps} | ||
| hideTitle={flyoutMenuHideTitle} | ||
| titleId={flyoutMenuId} | ||
| /> | ||
| ) : ( | ||
| !hideCloseButton && ( | ||
| <EuiFlyoutCloseButton | ||
| {...closeButtonProps} | ||
| onClose={handleClose} | ||
| closeButtonPosition={closeButtonPosition} | ||
| side={side} | ||
| /> | ||
| ) |
There was a problem hiding this comment.
doubt:
What if the consumer uses auto mode (which it is by default) and hideCloseButton: true? There would be no close button at all. It's an unlikely case but could happen...
There was a problem hiding this comment.
I thought about this as well but documentation is clear, if using hideCloseButton, independently of the menu display mode, consumers must provide another close button somewhere in the flyout:
/**
* Hides the default close button. You must provide another close button somewhere within the flyout.
* @default false
*/
hideCloseButton?: boolean;
5f55d2a to
3727d25
Compare
|
Thanks for reviewing and testing @weronikaolejniczak 🙇♀️ I increased test coverage with the missing test cases you suggested and applied your other comments. |
weronikaolejniczak
left a comment
There was a problem hiding this comment.
The latest updates LGTM! 🟢 I did a quick smoke-test in Storybook and it's still working as expected. Thank you, @angeles-mb! 🚢
💚 Build SucceededHistory
cc @angeles-mb |
💚 Build Succeeded
History
cc @angeles-mb |
Summary
This PR:
flyoutMenuDisplayModeprop toEuiFlyoutto control when the flyout menu bar is rendered:'auto'(default): Menu only renders when it has meaningful content (back button, history, visible title, or custom actions).'always': Menu always renders, this might result in a menu with nothing else than a close button.mainFlyoutMenuDisplayMode,childFlyoutMenuDisplayMode,showMainCustomActionsandshowChildCustomActions.Why are we making this change?
This change hides the menu when it only displays a close button and thus save some flyout space. Additionally, it gives consumers control over the menu bar visibility, allowing them to opt into
'always'mode.Closes https://github.com/elastic/kibana-team/issues/2670.
Screenshots #
Before: main shows menu even if there is no meaningful content (no mode, menu always shown):

After: main hides menu because there is no meaningful content (

'auto'default):After: main shows menu because there is meaningful content (either

'auto'default or'always'mode):After: main shows menu even if there is no meaningful content (

'always'mode):Testing in kibana:
Before: main shows menu even if there is no meaningful content (no mode, menu always shown):

Before: main shows menu and there is meaningful content (no mode, menu always shown):

After: main hides menu because there is no meaningful content (

'auto'default):After: main shows menu because there is meaningful content (either

'auto'default or'always'mode):Testing checklist:
Storybook
EuiFlyout > Flyout Manager > Playground:autoshowChildCustomActionsto false, menu still renders (with title)showChildCustomActionsto false, togglechildFlyoutMenuDisplayModetoalwaysmenu still renders (with title)showMainCustomActionsto false, menu does not render, stand alone close button renders insteadshowMainCustomActionsto false, togglemainFlyoutMenuDisplayModetoalwaysmenu renders with only a close button insideStorybook
EuiFlyout > EuiFlyout > Playground:autoshowCustomActionsto false, menu does not render, stand alone close button renders insteadshowCustomActionsto false, toggleflyoutMenuDisplayModetoalwaysmenu renders with only a close button insideKibana flyout examples:
If you want to test in kibana follow these instructions to test kibana against this branch. Test the System flyouts in the Flyout System Example (search for it on the global search bar)
Impact to users
Flyout users will stop seeing an empty menu which only contains a close button when there is no meaningful content.
QA
Remove or strikethrough items that do not apply to your PR.
General checklist
Checked in both MacOS and Windows high contrast modesChecked in mobileChecked for accessibility including keyboard-only and screenreader modes@defaultif default values are missing) and playground togglesChecked Code Sandbox works for any docs examplesUpdated visual regression testsIf applicable, added the breaking change issue label (and filled out the breaking change checklist)If the changes unblock an issue in a different repo, smoke tested carefully (see Testing EUI features in Kibana ahead of time)If applicable, file an issue to update EUI's Figma library with any corresponding UI changes.(This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)