Skip to content

Commit 19d9565

Browse files
Deepak-KharahKaushik Shetty
authored andcommitted
feat: prevent user from accidentally closing frame
1 parent 5466858 commit 19d9565

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

__test__/fieldModifierLocation/frame.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,22 @@ describe("FieldModifierLocationFrame", () => {
185185
expect(sendToParent).toHaveBeenLastCalledWith("closeModal");
186186
});
187187
});
188+
189+
describe("preventFrameClose", () => {
190+
it("should not allow user from clicking background", async () => {
191+
await frameInstance.setAllowAppClose(false);
192+
expect(sendToParent).toHaveBeenCalledTimes(1);
193+
expect(sendToParent).toHaveBeenLastCalledWith("setAllowAppClose", {
194+
isAllowed: false,
195+
});
196+
});
197+
198+
it("should allow user from clicking background", async () => {
199+
await frameInstance.setAllowAppClose(true);
200+
expect(sendToParent).toHaveBeenCalledTimes(1);
201+
expect(sendToParent).toHaveBeenLastCalledWith("setAllowAppClose", {
202+
isAllowed: true,
203+
});
204+
});
205+
});
188206
});

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/fieldModifierLocation/frame.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ declare class FieldModifierLocationFrame {
2323
height?: number;
2424
width?: number;
2525
}): Promise<void>;
26+
/**
27+
* Prevent user from accidently closing the app by clicking outside the frame
28+
* if the app is performing some active task.
29+
*/
30+
setAllowAppClose(isAllowed: boolean): Promise<void>;
2631
/**
2732
* This method enables auto resizing of the extension height.
2833
* @return {FieldModifierLocationFrame}.

dist/src/fieldModifierLocation/frame.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fieldModifierLocation/frame.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ class FieldModifierLocationFrame {
8989
}
9090
}
9191

92+
/**
93+
* Prevent user from accidently closing the app by clicking outside the frame
94+
* if the app is performing some active task.
95+
*/
96+
async setAllowAppClose(isAllowed: boolean) {
97+
await this._connection.sendToParent("setAllowAppClose", {
98+
isAllowed,
99+
});
100+
}
101+
92102
/**
93103
* This method enables auto resizing of the extension height.
94104
* @return {FieldModifierLocationFrame}.

0 commit comments

Comments
 (0)