Skip to content
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

feat: prevent user from accidentally closing frame #79

Merged
merged 2 commits into from
Jul 6, 2023
Merged
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
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 to close frame by clicking background", async () => {
await frameInstance.preventFrameClose(true);
expect(sendToParent).toHaveBeenCalledTimes(1);
expect(sendToParent).toHaveBeenLastCalledWith("preventFrameClose", {
state: true,
});
});

it("should allow user to close frame by clicking background", async () => {
await frameInstance.preventFrameClose(false);
expect(sendToParent).toHaveBeenCalledTimes(1);
expect(sendToParent).toHaveBeenLastCalledWith("preventFrameClose", {
state: false,
});
});
});
});
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.
*/
preventFrameClose(state: 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 preventFrameClose(state: boolean) {
await this._connection.sendToParent("preventFrameClose", {
state,
});
}

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