Skip to content

Commit

Permalink
feat(react-popup-manager) - adding 'response' to return value of `ope…
Browse files Browse the repository at this point in the history
…n` popup. is resolved after modal is closed.

#pr-cr@itaya,nitzansi,alexko
  • Loading branch information
varzager committed Aug 29, 2024
1 parent e504790 commit 8150cc6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/PopupsWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class PopupsWrapper extends React.Component<PopupsWrapperProps> {
this.props.popupManager.subscribeOnPopupsChange(() => this.forceUpdate());
}

private onClose(guid: string, result: any) {
this.props.popupManager.close(guid, result);
private onClose(guid: string, onAfterClose?: Function) {
this.props.popupManager.close(guid, onAfterClose);
}

public render() {
Expand Down
14 changes: 2 additions & 12 deletions src/__internal__/PopupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,10 @@ export class PopupItem {
this._resolve();
}

let result: any;
let error: any;
try {
result = await onAfterClose();
this._resolve(await onAfterClose());
} catch (ex) {
error = ex;
}

if (error) {
this._reject(error);
} else if (result) {
this._resolve(result);
} else {
this._resolve();
this._reject(ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {generateDataHook, TestPopupUsesIsOpen} from "../TestPopupUsesIsOpen/Test
import {PopupManager} from "../../popupManager";
import {TestPopupsDriver} from "../TestPopups.driver";

describe('TestPopupUsesIsOpen', () => {
describe('testPopups - "response" ', () => {
let driver: TestPopupsDriver;
const buttonOpenDataHook = 'button-open';

Expand Down

0 comments on commit 8150cc6

Please sign in to comment.