Skip to content

Commit

Permalink
Fix scrollLock causing nested popovers to be unable to scroll in Ki…
Browse files Browse the repository at this point in the history
…bana

- using a workaround recommended by `react-focus-on`'s author
  • Loading branch information
cee-chen committed Apr 28, 2023
1 parent b453bfe commit 4412a1f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"react-focus-on": "^3.7.0",
"react-input-autosize": "^3.0.0",
"react-is": "^17.0.2",
"react-remove-scroll-bar": "^2.3.4",
"react-virtualized-auto-sizer": "^1.0.6",
"react-window": "^1.8.6",
"refractor": "^3.5.0",
Expand Down
15 changes: 13 additions & 2 deletions src/components/focus_trap/focus_trap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React, { Component, CSSProperties } from 'react';
import { FocusOn } from 'react-focus-on';
import { ReactFocusOnProps } from 'react-focus-on/dist/es5/types';
import { RemoveScrollBar } from 'react-remove-scroll-bar';

import { CommonProps } from '../common';
import { findElementBySelectorOrRef, ElementTarget } from '../../services';
Expand Down Expand Up @@ -124,11 +125,21 @@ export class EuiFocusTrap extends Component<EuiFocusTrapProps, State> {
const focusOnProps = {
returnFocus,
noIsolation,
scrollLock,
enabled: !isDisabled,
...rest,
onClickOutside: this.handleOutsideClick,
/**
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
* @see https://github.com/theKashey/react-focus-on/issues/49
*/
scrollLock: false,
};
return <FocusOn {...focusOnProps}>{children}</FocusOn>;
return (
<FocusOn {...focusOnProps}>
{children}
{scrollLock && <RemoveScrollBar />}
</FocusOn>
);
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14450,7 +14450,7 @@ react-refresh@^0.11.0:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==

react-remove-scroll-bar@^2.3.3:
react-remove-scroll-bar@^2.3.3, react-remove-scroll-bar@^2.3.4:
version "2.3.4"
resolved "https://registry.yarnpkg.com/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.4.tgz#53e272d7a5cb8242990c7f144c44d8bd8ab5afd9"
integrity sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==
Expand Down

0 comments on commit 4412a1f

Please sign in to comment.