Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Scroll window back to original position after scroll (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-PatrickOFriel authored Jul 26, 2017
1 parent 69d3667 commit 96f3775
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modules/modal/modal-component-adapter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -97,6 +100,7 @@ export class SkyModalComponentAdapterService {
focusEl.focus();

}
window.scrollTo(currentScrollX, currentScrollY);
}
}

Expand Down

0 comments on commit 96f3775

Please sign in to comment.