Skip to content

Commit

Permalink
feat: prevent user from accidentally closing frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak-Kharah authored and Kaushik Shetty committed Jul 6, 2023
1 parent 5466858 commit 19d9565
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
18 changes: 18 additions & 0 deletions __test__/fieldModifierLocation/frame.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,22 @@ describe("FieldModifierLocationFrame", () => {
expect(sendToParent).toHaveBeenLastCalledWith("closeModal");
});
});

describe("preventFrameClose", () => {
it("should not allow user from clicking background", async () => {
await frameInstance.setAllowAppClose(false);
expect(sendToParent).toHaveBeenCalledTimes(1);
expect(sendToParent).toHaveBeenLastCalledWith("setAllowAppClose", {
isAllowed: false,
});
});

it("should allow user from clicking background", async () => {
await frameInstance.setAllowAppClose(true);
expect(sendToParent).toHaveBeenCalledTimes(1);
expect(sendToParent).toHaveBeenLastCalledWith("setAllowAppClose", {
isAllowed: true,
});
});
});
});
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions dist/src/fieldModifierLocation/frame.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ declare class FieldModifierLocationFrame {
height?: number;
width?: number;
}): Promise<void>;
/**
* Prevent user from accidently closing the app by clicking outside the frame
* if the app is performing some active task.
*/
setAllowAppClose(isAllowed: boolean): Promise<void>;
/**
* This method enables auto resizing of the extension height.
* @return {FieldModifierLocationFrame}.
Expand Down
2 changes: 1 addition & 1 deletion dist/src/fieldModifierLocation/frame.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/fieldModifierLocation/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ class FieldModifierLocationFrame {
}
}

/**
* Prevent user from accidently closing the app by clicking outside the frame
* if the app is performing some active task.
*/
async setAllowAppClose(isAllowed: boolean) {
await this._connection.sendToParent("setAllowAppClose", {
isAllowed,
});
}

/**
* This method enables auto resizing of the extension height.
* @return {FieldModifierLocationFrame}.
Expand Down

0 comments on commit 19d9565

Please sign in to comment.