-
Notifications
You must be signed in to change notification settings - Fork 862
[EuiFlyout] Enable shards for scoping element clicks; Optionally delay close event
#5860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
93b1445
enable shards; add default button shard for collapsible nav
thompsongl 251f4bb
elastic pattern spec
thompsongl 389e017
update comment
thompsongl ae1acc2
CL
thompsongl 83c38dc
closeOnMouseup to delay close
thompsongl e16f22d
TEMP: remove shard from collapsible
thompsongl a461586
focusTrapProps to match pattern in EuiPopover
thompsongl 4853603
initial docs
thompsongl 6ca7663
clean up
thompsongl fdfea7d
use focusTrapProps in EuiCollapsibleNav
thompsongl 8e1a91b
docs and tests
thompsongl 4df8b32
default to mousedown
thompsongl ab60381
consolidate spec children
thompsongl 3ed9263
Merge branch 'main' into flyout-shards
thompsongl 9dbc340
cypress tests
thompsongl 31d35df
update function names
thompsongl 4f349d4
remove flyout tests
thompsongl 41a02a3
update focus_trap cypress tests
thompsongl af136d2
Merge branch 'main' into flyout-shards
thompsongl a097159
remove docs
thompsongl 271606d
code comments
thompsongl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| /// <reference types="../../../cypress/support"/> | ||
|
|
||
| import React, { useState } from 'react'; | ||
|
|
||
| import { EuiCollapsibleNav } from './collapsible_nav'; | ||
| import { EuiHeader, EuiHeaderSectionItemButton } from '../header'; | ||
| import { EuiIcon } from '../icon'; | ||
|
|
||
| const Nav = () => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
|
|
||
| return ( | ||
| <EuiHeader | ||
| style={{ zIndex: 1001 }} | ||
| position="fixed" | ||
| sections={[ | ||
| { | ||
| items: [ | ||
| <EuiCollapsibleNav | ||
| style={{ top: 48 }} | ||
| id="navSpec" | ||
| isOpen={isOpen} | ||
| button={ | ||
| <EuiHeaderSectionItemButton | ||
| data-test-subj="navSpecButton" | ||
| aria-label="Toggle main navigation" | ||
| onClick={() => setIsOpen(!isOpen)} | ||
| > | ||
| <EuiIcon type={'menu'} size="m" aria-hidden="true" /> | ||
| </EuiHeaderSectionItemButton> | ||
| } | ||
| onClose={() => setIsOpen(false)} | ||
| > | ||
| <button data-test-subj="itemA">Item A</button> | ||
| <button data-test-subj="itemB">Item B</button> | ||
| <button data-test-subj="itemC">Item C</button> | ||
| <input data-test-subj="itemD" /> | ||
| </EuiCollapsibleNav>, | ||
| ], | ||
| }, | ||
| ]} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| describe('EuiCollapsibleNav', () => { | ||
| describe('Elastic pattern', () => { | ||
| describe('Toggle button behavior', () => { | ||
| it('opens and closes nav when the main button is clicked', () => { | ||
| cy.mount(<Nav />); | ||
| cy.wait(400); // Wait for the button to be clickable | ||
| cy.get('[data-test-subj="navSpecButton"]').realClick(); | ||
| expect(cy.get('#navSpec').should('exist')); | ||
| cy.get('[data-test-subj="navSpecButton"]').realClick(); | ||
| expect(cy.get('#navSpec').should('not.exist')); | ||
| }); | ||
|
|
||
| it('closes the nav when the overlay mask is clicked', () => { | ||
| cy.mount(<Nav />); | ||
| cy.wait(400); | ||
| cy.get('[data-test-subj="navSpecButton"]').realClick(); | ||
| cy.get('.euiOverlayMask').realClick(); | ||
| expect(cy.get('#navSpec').should('not.exist')); | ||
| }); | ||
|
|
||
| it('closes the nav when the close button is clicked', () => { | ||
| cy.mount(<Nav />); | ||
| cy.wait(400); | ||
| cy.get('[data-test-subj="navSpecButton"]').realClick(); | ||
| cy.get('[data-test-subj="euiFlyoutCloseButton"]').realClick(); | ||
| expect(cy.get('#navSpec').should('not.exist')); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| - Added the `focusTrapProps` prop to `EuiFlyout` to aid outside click detection and closing event | ||
|
|
||
| **Bug fixes** | ||
|
|
||
| - Fixed `EuiCollapsibleNav` failing to close when the button is clicked | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.