Skip to content

Commit

Permalink
[EuiFlyout] Preserve scrollbar width on body when EuiFlyout is open (
Browse files Browse the repository at this point in the history
…#6645)

* Fix EuiFlyouts to no longer cause page width jump on focus trap open

- `ownFocus={false}` and push flyouts should not focus/scroll lock

* [misc] Add scroll lock fixes to other fullscreen modes

* changelog
  • Loading branch information
cee-chen authored Mar 20, 2023
1 parent e76c07e commit ec75a84
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/code/code_block_full_screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const EuiCodeBlockFullScreenWrapper: FunctionComponent = ({

return (
<EuiOverlayMask>
<EuiFocusTrap clickOutsideDisables={true}>
<EuiFocusTrap scrollLock preventScrollOnFocus clickOutsideDisables={true}>
<div className="euiCodeBlockFullScreen" css={cssStyles}>
{children}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/flyout/flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ export const EuiFlyout = forwardRef(
let flyout = (
<EuiFocusTrap
disabled={isPushed}
scrollLock={ownFocus}
clickOutsideDisables={!ownFocus}
onClickOutside={onClickOutside}
{...focusTrapProps}
Expand Down
6 changes: 5 additions & 1 deletion src/components/image/image_fullscreen_wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export const EuiImageFullScreenWrapper: FunctionComponent<EuiImageWrapperProps>

return (
<EuiOverlayMask data-test-subj="fullScreenOverlayMask">
<EuiFocusTrap onClickOutside={closeFullScreen}>
<EuiFocusTrap
scrollLock
preventScrollOnFocus
onClickOutside={closeFullScreen}
>
<>
<figure
aria-label={optionalCaptionText}
Expand Down
5 changes: 5 additions & 0 deletions upcoming_changelogs/6645.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**Bug fixes**

- Fixed `EuiFlyout` to preserve body scrollbar width on open
- Fixed `EuiImage`'s full screen mode to not scroll jump & to preserve body scrollbar width on open
- Fixed `EuiCodeBlock`'s full screen mode to not scroll jump & to preserve body scrollbar width on open

0 comments on commit ec75a84

Please sign in to comment.