-
Notifications
You must be signed in to change notification settings - Fork 840
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
[EuiPopover] Fix popover returning focus to correct element #4071
Merged
chandlerprall
merged 13 commits into
elastic:master
from
chandlerprall:bug/4003-popover-re-focus
Nov 4, 2020
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cf88a0c
Move onclickoutside / onescape handling to focus-lock lib itself
chandlerprall 7c97d64
Get popover focus return functioning
chandlerprall a587534
Fix lint issues & snapshots, re-enable clickOutsideDisables prop for …
chandlerprall bc5b666
fix popover re-toggling when clicking its anchor
chandlerprall 172af2d
Re-enable popover outside click and escape key detection when ownFocu…
chandlerprall 5bc02fb
Only call popover's closePopover callback when it is open
chandlerprall 374c41b
Don't scroll back to a popover anchor when the popover closes
chandlerprall 6d6e1be
Address unintentional changes to flyouts & color picker
chandlerprall baebfb1
Merge branch 'master' into bug/4003-popover-re-focus
chandlerprall 206c7b0
changelog
chandlerprall ae58e17
Merge branch 'master' into bug/4003-popover-re-focus
chandlerprall a68536b
revert changes to popover example, which had been made to augment tes…
chandlerprall 3e99a23
Fix flyout's snapshot tests
chandlerprall 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 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 |
---|---|---|
@@ -1,29 +1,34 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { EuiPopover, EuiButton, EuiText } from '../../../../src/components'; | ||
import { EuiPopover, EuiButton } from '../../../../src/components'; | ||
|
||
export default () => { | ||
const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
|
||
const onButtonClick = () => | ||
setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen); | ||
const closePopover = () => setIsPopoverOpen(false); | ||
|
||
const button = ( | ||
<EuiButton iconType="arrowDown" iconSide="right" onClick={onButtonClick}> | ||
Show popover | ||
</EuiButton> | ||
); | ||
const [openPopover, setOpenPopover] = useState(null); | ||
|
||
return ( | ||
<EuiPopover | ||
ownFocus | ||
button={button} | ||
isOpen={isPopoverOpen} | ||
closePopover={closePopover}> | ||
<EuiText style={{ width: 300 }}> | ||
<p>Popover content that’s wider than the default width</p> | ||
</EuiText> | ||
</EuiPopover> | ||
<> | ||
{[0, 1, 2, 3, 4].map((idx) => ( | ||
<div key={idx}> | ||
<EuiPopover | ||
anchorPosition="rightCenter" | ||
ownFocus | ||
button={ | ||
<EuiButton | ||
data-idx={idx} | ||
iconType="arrowDown" | ||
iconSide="right" | ||
onClick={() => setOpenPopover(idx)}> | ||
Show popover | ||
</EuiButton> | ||
} | ||
isOpen={openPopover === idx} | ||
closePopover={() => setOpenPopover(null)}> | ||
<div style={{ width: '300px' }}> | ||
Popover content that’s wider than the default width | ||
</div> | ||
</EuiPopover> | ||
</div> | ||
))} | ||
</> | ||
); | ||
}; |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is temporary, for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to revert this before merging. 😜