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] Allow content to be accessible during opening animation #5249

Merged
merged 8 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
95 changes: 61 additions & 34 deletions src-docs/src/views/progress/progress_chart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React, { Fragment } from 'react';

import { EuiProgress, EuiSpacer } from '../../../../src/components';
import {
EuiBadge,
EuiPopover,
EuiButton,
EuiProgress,
EuiSpacer,
} from '../../../../src/components';

const data = [
{ label: 'Basic percentage', value: '80' },
Expand All @@ -13,36 +19,57 @@ const data = [
{ label: "Women's Accessories", value: '24.0256' },
];

export default () => (
<Fragment>
<div style={{ maxWidth: 160 }}>
{data.map((item) => (
<>
<EuiProgress
valueText={true}
max={100}
color="success"
size="s"
{...item}
/>
<EuiSpacer size="s" />
</>
))}
</div>
<EuiSpacer size="m" />
<div style={{ maxWidth: 200 }}>
{data.map((item) => (
<>
<EuiProgress
valueText={true}
max={100}
color="primary"
size="m"
{...item}
/>
<EuiSpacer size="s" />
</>
))}
</div>
</Fragment>
);
export default () => {
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);

const onButtonClick = () =>
setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen);
const closePopover = () => setIsPopoverOpen(false);

const button = (
<EuiButton iconType="arrowDown" iconSide="right" onClick={onButtonClick}>
Show popover
</EuiButton>
);

return (
<Fragment>
<EuiPopover
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}
>
<EuiBadge>Text</EuiBadge>
<div style={{ maxWidth: 160 }}>
{data.map((item) => (
<>
<EuiProgress
valueText={true}
max={100}
color="success"
size="s"
{...item}
/>
<EuiSpacer size="s" />
</>
))}
</div>
<EuiSpacer size="m" />
<div style={{ maxWidth: 200 }}>
{data.map((item) => (
<>
<EuiProgress
valueText={true}
max={100}
color="primary"
size="m"
{...item}
/>
<EuiSpacer size="s" />
</>
))}
</div>
</EuiPopover>
</Fragment>
);
};
2 changes: 0 additions & 2 deletions src/components/popover/_popover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
backface-visibility: hidden;
pointer-events: none;
opacity: 0; /* 2 */
visibility: hidden; /* 2 */
transition: /* 2 */
opacity $euiAnimSlightBounce $euiAnimSpeedSlow,
visibility $euiAnimSlightBounce $euiAnimSpeedSlow;
Expand All @@ -54,7 +53,6 @@

&.euiPopover__panel-isOpen {
opacity: 1;
visibility: visible;
pointer-events: auto;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ export class EuiPopover extends Component<Props, State> {
// there isn't a focus target, one of two reasons:
// #1 is the whole panel hidden? If so, schedule another check
// #2 panel is visible but no tabbables exist, move focus to the panel
const panelVisibility = window.getComputedStyle(this.panel).visibility;
if (panelVisibility === 'hidden') {
const panelVisibility = window.getComputedStyle(this.panel).opacity;
if (panelVisibility === '0') {
// #1
this.updateFocus();
} else {
Expand Down