Skip to content

Commit f7e4d9e

Browse files
committed
Use focusWithoutScrolling when restoring focus
1 parent 4a6f3df commit f7e4d9e

File tree

1 file changed

+3
-3
lines changed
  • packages/@react-aria/interactions/src

1 file changed

+3
-3
lines changed

packages/@react-aria/interactions/src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import {FocusableElement} from '@react-types/shared';
14-
import {getOwnerWindow, isFocusable, useEffectEvent, useLayoutEffect} from '@react-aria/utils';
14+
import {focusWithoutScrolling, getOwnerWindow, isFocusable, useEffectEvent, useLayoutEffect} from '@react-aria/utils';
1515
import {FocusEvent as ReactFocusEvent, useCallback, useRef} from 'react';
1616

1717
export class SyntheticFocusEvent<Target = Element> implements ReactFocusEvent<Target> {
@@ -165,7 +165,7 @@ export function preventFocus(target: FocusableElement | null) {
165165
// Re-focus the original active element here.
166166
if (!target && !isRefocusing) {
167167
isRefocusing = true;
168-
activeElement.focus();
168+
focusWithoutScrolling(activeElement);
169169
cleanup();
170170
}
171171
}
@@ -183,7 +183,7 @@ export function preventFocus(target: FocusableElement | null) {
183183

184184
if (!isRefocusing) {
185185
isRefocusing = true;
186-
activeElement.focus();
186+
focusWithoutScrolling(activeElement);
187187
cleanup();
188188
}
189189
}

0 commit comments

Comments
 (0)