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

Commit

Permalink
Handle async control flow when closing raw modal
Browse files Browse the repository at this point in the history
Issue #1361
  • Loading branch information
pablosichert committed Jan 13, 2018
1 parent d4e6e37 commit 637b012
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/components/app/RawModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,33 @@ class RawModal extends Component {
});
};

handleClose = () => {
handleClose = async () => {
const { closeCallback, viewId, windowType } = this.props;
const { isNew } = this.state;

if (closeCallback) {
closeCallback(isNew);
await closeCallback(isNew);
}

deleteView(windowType, viewId);
await deleteView(windowType, viewId);

this.removeModal();
await this.removeModal();
};

removeModal = () => {
removeModal = async () => {
const { dispatch, modalVisible, windowType, viewId } = this.props;

dispatch(closeRawModal());
dispatch(closeModal());
dispatch(
for (const action of [
closeRawModal(),
closeModal(),
closeListIncludedView({
windowType,
viewId,
forceClose: true
})
);
]) {
await dispatch(action);
}

if (!modalVisible) {
document.body.style.overflow = "auto";
Expand Down
4 changes: 2 additions & 2 deletions src/containers/MasterWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ class MasterWindow extends Component {
closeModalCallback = (
{ isNew, windowType, documentId, tabId, rowId } = {}
) => {
if (isNew) {
discardNewRow({ windowType, documentId, tabId, rowId });
if (!isNew) {
return discardNewRow({ windowType, documentId, tabId, rowId });
}
};

Expand Down

0 comments on commit 637b012

Please sign in to comment.