Skip to content

Commit

Permalink
[core][material-ui] Prevent scrolling when restoring after FocusTrap
Browse files Browse the repository at this point in the history
Fixes mui#43299
  • Loading branch information
joshkel committed Aug 14, 2024
1 parent 8968394 commit d1774c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/mui-base/src/FocusTrap/FocusTrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function FocusTrap(props: FocusTrapProps): React.JSX.Element {
// Once IE11 support is dropped the focus() call can be unconditional.
if (nodeToRestore.current && (nodeToRestore.current as HTMLElement).focus) {
ignoreNextEnforceFocus.current = true;
(nodeToRestore.current as HTMLElement).focus();
(nodeToRestore.current as HTMLElement).focus({ preventScroll: true });
}

nodeToRestore.current = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Unstable_TrapFocus/FocusTrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function FocusTrap(props: FocusTrapProps): React.JSX.Element {
// Once IE11 support is dropped the focus() call can be unconditional.
if (nodeToRestore.current && (nodeToRestore.current as HTMLElement).focus) {
ignoreNextEnforceFocus.current = true;
(nodeToRestore.current as HTMLElement).focus();
(nodeToRestore.current as HTMLElement).focus({ preventScroll: true });
}

nodeToRestore.current = null;
Expand Down

0 comments on commit d1774c0

Please sign in to comment.