Skip to content
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
merged 13 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from 8 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
47 changes: 26 additions & 21 deletions src-docs/src/views/popover/popover.js
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);
Copy link
Contributor Author

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

Copy link
Contributor

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. 😜


return (
<EuiPopover
ownFocus
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}>
<EuiText style={{ width: 300 }}>
<p>Popover content that&rsquo;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&rsquo;s wider than the default width
</div>
</EuiPopover>
</div>
))}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
panelPaddingSize="none"
>
<EuiOutsideClickDetector
isDisabled={true}
onOutsideClick={[Function]}
>
<div
Expand Down
Loading