From 29f568a7c505d165726c45289e9ca05b6d9e7802 Mon Sep 17 00:00:00 2001 From: Blackbaud-PatrickOFriel Date: Wed, 26 Jul 2017 15:21:32 -0400 Subject: [PATCH] Scroll window back to original position after scroll --- src/modules/modal/modal-component-adapter.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/modal/modal-component-adapter.service.ts b/src/modules/modal/modal-component-adapter.service.ts index b8bc5fb5c..49dd4db74 100644 --- a/src/modules/modal/modal-component-adapter.service.ts +++ b/src/modules/modal/modal-component-adapter.service.ts @@ -88,6 +88,9 @@ export class SkyModalComponentAdapterService { /* istanbul ignore else */ /* handle the case where somehow there is a focused element already in the modal */ if (!(document.activeElement && modalEl.nativeElement.contains(document.activeElement))) { + let currentScrollX = window.pageXOffset; + let currentScrollY = window.pageYOffset; + let inputWithAutofocus = modalEl.nativeElement.querySelector('[autofocus]'); if (inputWithAutofocus) { @@ -97,6 +100,7 @@ export class SkyModalComponentAdapterService { focusEl.focus(); } + window.scrollTo(currentScrollX, currentScrollY); } }