Skip to content

Commit

Permalink
[Lens] setFocusTrap after animation is ended and not with timeout (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra authored and kibanamachine committed Jun 3, 2021
1 parent 70bd851 commit 6d80ad3
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ export function DimensionContainer({
setFocusTrapIsEnabled(false);
}, [handleClose]);

useEffect(() => {
if (isOpen) {
// without setTimeout here the flyout pushes content when animating
setTimeout(() => {
setFocusTrapIsEnabled(true);
}, 255);
}
}, [isOpen]);

const closeOnEscape = useCallback(
(event: KeyboardEvent) => {
if (event.key === keys.ESCAPE) {
Expand Down Expand Up @@ -83,6 +74,13 @@ export function DimensionContainer({
role="dialog"
aria-labelledby="lnsDimensionContainerTitle"
className="lnsDimensionContainer euiFlyout"
onAnimationEnd={() => {
if (isOpen) {
// EuiFocusTrap interferes with animating elements with absolute position:
// running this onAnimationEnd, otherwise the flyout pushes content when animating
setFocusTrapIsEnabled(true);
}
}}
>
<EuiFlyoutHeader hasBorder className="lnsDimensionContainer__header">
<EuiFlexGroup
Expand Down

0 comments on commit 6d80ad3

Please sign in to comment.