Skip to content

Commit 3f4bcce

Browse files
committed
fix: Fix bug that caused inadvertent scrolling when the WidgetDiv was shown.
1 parent 7d1d745 commit 3f4bcce

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

core/focus_manager.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ export class FocusManager {
309309
* Note that this may update the specified node's element's tabindex to ensure
310310
* that it can be properly read out by screenreaders while focused.
311311
*
312+
* The focused node will not be automatically scrolled into view.
313+
*
312314
* @param focusableNode The node that should receive active focus.
313315
*/
314316
focusNode(focusableNode: IFocusableNode): void {
@@ -423,6 +425,8 @@ export class FocusManager {
423425
* the returned lambda is called. Additionally, only 1 ephemeral focus context
424426
* can be active at any given time (attempting to activate more than one
425427
* simultaneously will result in an error being thrown).
428+
*
429+
* This method does not scroll the ephemerally focused node into view.
426430
*/
427431
takeEphemeralFocus(
428432
focusableElement: HTMLElement | SVGElement,
@@ -439,7 +443,7 @@ export class FocusManager {
439443
if (this.focusedNode) {
440444
this.passivelyFocusNode(this.focusedNode, null);
441445
}
442-
focusableElement.focus();
446+
focusableElement.focus({preventScroll: true});
443447

444448
let hasFinishedEphemeralFocus = false;
445449
return () => {
@@ -574,7 +578,7 @@ export class FocusManager {
574578
}
575579

576580
this.setNodeToVisualActiveFocus(node);
577-
elem.focus();
581+
elem.focus({preventScroll: true});
578582
}
579583

580584
/**

core/interfaces/i_focusable_node.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export interface IFocusableNode {
5959
* they should avoid the following:
6060
* - Creating or removing DOM elements (including via the renderer or drawer).
6161
* - Affecting focus via DOM focus() calls or the FocusManager.
62+
*
63+
* Implementations should consider scrolling themselves into view here; that
64+
* is not handled by the focus manager.
6265
*/
6366
onNodeFocus(): void;
6467

0 commit comments

Comments
 (0)