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

[EuiFlyout] Fix broken push flyout behavior #6764

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions src/components/flyout/flyout.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ describe('EuiFlyout', () => {
'euiFlyoutCloseButton'
);
});

it('does not focus trap or scrollLock for push flyouts', () => {
cy.mount(
<>
<div style={{ height: 2000 }}>Body scroll</div>
<Flyout type="push" pushMinBreakpoint="xs" size="100px" />
</>
);

cy.get('body').realClick({ position: 'topLeft' }).realPress('End'); // TODO: Use cypress-real-event's `realMouseWheel` API, whenever they release it
cy.wait(500); // Wait a tick to let scroll position update
cy.window().its('scrollY').should('not.equal', 0);
});
});

describe('Close behavior: standard', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/flyout/flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export const EuiFlyout = forwardRef(
let flyout = (
<EuiFocusTrap
disabled={isPushed}
scrollLock={ownFocus}
scrollLock={hasOverlayMask}
clickOutsideDisables={!ownFocus}
onClickOutside={onClickOutside}
{...focusTrapProps}
Expand Down
13 changes: 13 additions & 0 deletions src/components/focus_trap/focus_trap.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,19 @@ describe('EuiFocusTrap', () => {
cy.window().its('scrollY').should('not.equal', 0);
});

it('does not scrollLock if the focus trap is disabled', () => {
cy.realMount(
<div style={{ height: 2000 }}>
<EuiFocusTrap disabled={true} scrollLock={true}>
Test
</EuiFocusTrap>
</div>
);

scrollSelector('body');
cy.window().its('scrollY').should('not.equal', 0);
});

it('prevents scrolling on the page body', () => {
cy.realMount(
<div style={{ height: 2000 }}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/focus_trap/focus_trap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class EuiFocusTrap extends Component<EuiFocusTrapProps, State> {
return (
<FocusOn {...focusOnProps}>
{children}
{scrollLock && <RemoveScrollBar gapMode={gapMode} />}
{!isDisabled && scrollLock && <RemoveScrollBar gapMode={gapMode} />}
</FocusOn>
);
}
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/6764.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed broken push `EuiFlyout` behavior