Bug 1563741 - Keeping body scroll static, but welcome modal centered … (#5162)

* Bug 1563741 - Keeping body scroll static, but welcome modal centered and scrollable

* Keeping content background static and allowing modal to scroll up and down window

* css typo

* Fixing test cases by mocking getElementById

* Checking existence of header for the cases where props.document isn't passed down
This commit is contained in:
Jeane Carlos 2019-07-16 14:03:50 -07:00 коммит произвёл GitHub
Родитель 0379c988b1
Коммит 53d3842089
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 35 добавлений и 2 удалений

Просмотреть файл

@ -19,11 +19,26 @@ export class ModalOverlayWrapper extends React.PureComponent {
componentWillMount() { componentWillMount() {
this.props.document.addEventListener("keydown", this.onKeyDown); this.props.document.addEventListener("keydown", this.onKeyDown);
this.props.document.body.classList.add("modal-open"); this.props.document.body.classList.add("modal-open");
this.header = this.props.document.getElementById(
"header-asrouter-container"
);
if (this.header) {
this.header.classList.add("modal-scroll");
this.props.document.getElementById("root").classList.add("modal-height");
}
} }
componentWillUnmount() { componentWillUnmount() {
this.props.document.removeEventListener("keydown", this.onKeyDown); this.props.document.removeEventListener("keydown", this.onKeyDown);
this.props.document.body.classList.remove("modal-open"); this.props.document.body.classList.remove("modal-open");
if (this.header) {
this.header.classList.remove("modal-scroll");
this.props.document
.getElementById("root")
.classList.remove("modal-height");
}
} }
render() { render() {

Просмотреть файл

@ -19,6 +19,19 @@
} }
} }
.modal-scroll {
position: absolute;
width: 100%;
height: 100%;
overflow: auto;
}
.modal-height {
// "Welcome header" has 40px of padding and 36px font size that get neglected using position absolute
// causing this to visually collide with the newtab searchbar
padding-top: 80px;
}
.modalOverlayInner { .modalOverlayInner {
width: 960px; width: 960px;
position: fixed; position: fixed;
@ -30,7 +43,6 @@
display: none; display: none;
z-index: 1101; z-index: 1101;
// modal takes over entire screen // modal takes over entire screen
@media(max-width: 960px) { @media(max-width: 960px) {
width: 100%; width: 100%;

Просмотреть файл

@ -401,7 +401,7 @@
.inline-onboarding { .inline-onboarding {
&.activity-stream.welcome { &.activity-stream.welcome {
overflow-y: scroll; overflow-y: hidden;
} }
.modalOverlayInner { .modalOverlayInner {

Просмотреть файл

@ -5,12 +5,18 @@ import React from "react";
describe("ModalOverlayWrapper", () => { describe("ModalOverlayWrapper", () => {
let fakeDoc; let fakeDoc;
let sandbox; let sandbox;
let header;
beforeEach(() => { beforeEach(() => {
sandbox = sinon.createSandbox(); sandbox = sinon.createSandbox();
header = document.createElement("div");
fakeDoc = { fakeDoc = {
addEventListener: sandbox.stub(), addEventListener: sandbox.stub(),
removeEventListener: sandbox.stub(), removeEventListener: sandbox.stub(),
body: { classList: { add: sandbox.stub(), remove: sandbox.stub() } }, body: { classList: { add: sandbox.stub(), remove: sandbox.stub() } },
getElementById() {
return header;
},
}; };
}); });
afterEach(() => { afterEach(() => {