Skip to content

Commit 206cfe6

Browse files
xaviergonzdiasbruno
authored andcommitted
ensure focus does not scroll the modal
In IOS we found that the focus of an element would scroll the page so such element is brought into view. In our case we have a grid of several views (iframes) and whenever a modal would appear on one of those views then the whole app would scroll to show the cell were the modal appeared, which is undesireable. This PR fixes that.
1 parent 9a4dde5 commit 206cfe6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/components/ModalPortal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export default class ModalPortal extends Component {
233233

234234
// Don't steal focus from inner elements
235235
focusContent = () =>
236-
this.content && !this.contentHasFocus() && this.content.focus();
236+
this.content && !this.contentHasFocus() && this.content.focus({ preventScroll: true });
237237

238238
closeWithTimeout = () => {
239239
const closesAt = Date.now() + this.props.closeTimeoutMS;

0 commit comments

Comments
 (0)