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

Modal scroll #950

Merged
merged 2 commits into from
Jul 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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