Skip to content

[fixed] Ensure after-open css transitions work in Safari 14 & Mobile Safari #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
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
21 changes: 14 additions & 7 deletions specs/Modal.events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,27 @@ import {
} from "./helper";

export default () => {
it("should trigger the onAfterOpen callback", () => {
it("should trigger the onAfterOpen callback", done => {
const afterOpenCallback = sinon.spy();
const props = { isOpen: true, onAfterOpen: afterOpenCallback };
withModal(props, null, () => {});
afterOpenCallback.called.should.be.ok();
withModal(props, null, () => {
requestAnimationFrame(() => {
afterOpenCallback.called.should.be.ok();
done();
});
});
});

it("should call onAfterOpen with overlay and content references", () => {
it("should call onAfterOpen with overlay and content references", done => {
const afterOpenCallback = sinon.spy();
const props = { isOpen: true, onAfterOpen: afterOpenCallback };
withModal(props, null, modal => {
sinon.assert.calledWith(afterOpenCallback, {
overlayEl: modal.portal.overlay,
contentEl: modal.portal.content
requestAnimationFrame(() => {
sinon.assert.calledWith(afterOpenCallback, {
overlayEl: modal.portal.overlay,
contentEl: modal.portal.content
});
done();
});
});
});
Expand Down
29 changes: 19 additions & 10 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export default () => {
});
});

it("overrides content classes with custom object className", () => {
it("overrides content classes with custom object className", done => {
const props = {
isOpen: true,
className: {
Expand All @@ -357,11 +357,14 @@ export default () => {
}
};
withModal(props, null, modal => {
mcontent(modal).className.should.be.eql("myClass myClass_after-open");
requestAnimationFrame(() => {
mcontent(modal).className.should.be.eql("myClass myClass_after-open");
done();
});
});
});

it("overrides overlay classes with custom object overlayClassName", () => {
it("overrides overlay classes with custom object overlayClassName", done => {
const props = {
isOpen: true,
overlayClassName: {
Expand All @@ -371,9 +374,12 @@ export default () => {
}
};
withModal(props, null, modal => {
moverlay(modal).className.should.be.eql(
"myOverlayClass myOverlayClass_after-open"
);
requestAnimationFrame(() => {
moverlay(modal).className.should.be.eql(
"myOverlayClass myOverlayClass_after-open"
);
done();
});
});
});

Expand Down Expand Up @@ -667,12 +673,15 @@ export default () => {
});
});

it("adds --after-open for animations", () => {
it("adds --after-open for animations", done => {
const props = { isOpen: true };
const rg = /--after-open/i;
withModal(props, null, modal => {
const rg = /--after-open/i;
rg.test(mcontent(modal).className).should.be.ok();
rg.test(moverlay(modal).className).should.be.ok();
requestAnimationFrame(() => {
rg.test(mcontent(modal).className).should.be.ok();
rg.test(moverlay(modal).className).should.be.ok();
done();
});
});
});

Expand Down
18 changes: 10 additions & 8 deletions src/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,16 @@ export default class ModalPortal extends Component {
}

this.setState({ isOpen: true }, () => {
this.setState({ afterOpen: true });

if (this.props.isOpen && this.props.onAfterOpen) {
this.props.onAfterOpen({
overlayEl: this.overlay,
contentEl: this.content
});
}
requestAnimationFrame(() => {
this.setState({ afterOpen: true });

if (this.props.isOpen && this.props.onAfterOpen) {
this.props.onAfterOpen({
overlayEl: this.overlay,
contentEl: this.content
});
}
});
});
}
};
Expand Down