diff --git a/src/client/automation/utils/utils.js b/src/client/automation/utils/utils.js index 44084693097..557e2c5999d 100644 --- a/src/client/automation/utils/utils.js +++ b/src/client/automation/utils/utils.js @@ -59,6 +59,10 @@ export function focusAndSetSelection (element, simulateFocus, caretPos) { return; } + var focusWithSilentMode = !simulateFocus; + var focusForMouseEvent = true; + var preventScrolling = false; + if (!isElementFocusable && !isContentEditable) { var curDocument = domUtils.findDocument(elementForFocus); var curActiveElement = curDocument.activeElement; @@ -76,12 +80,10 @@ export function focusAndSetSelection (element, simulateFocus, caretPos) { return; } - elementForFocus = focusableParent || curDocument.body; + elementForFocus = focusableParent || curDocument.body; + preventScrolling = true; } - var focusWithSilentMode = !simulateFocus; - var focusForMouseEvent = true; - focusBlurSandbox.focus(elementForFocus, () => { // NOTE: if a different element was focused in the focus event handler, we should not set selection if (simulateFocus && !isContentEditable && element !== domUtils.getActiveElement()) { @@ -97,7 +99,7 @@ export function focusAndSetSelection (element, simulateFocus, caretPos) { focusBlurSandbox.focus(activeElement, resolve, true, true); else resolve(); - }, focusWithSilentMode, focusForMouseEvent); + }, focusWithSilentMode, focusForMouseEvent, false, preventScrolling); }); } diff --git a/test/functional/fixtures/regression/gh-913/pages/index.html b/test/functional/fixtures/regression/gh-913/pages/index.html new file mode 100644 index 00000000000..4283a4fe2b7 --- /dev/null +++ b/test/functional/fixtures/regression/gh-913/pages/index.html @@ -0,0 +1,11 @@ + + +
+