feat: Add prop autoFocus
to set focus on the Excalidraw component (#3691)
* feat: Add prop autofocus to set focus on Excalidraw component * Update PR number * Make requested changes * Add note * Update src/packages/excalidraw/CHANGELOG.md Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com> * Update src/tests/excalidrawPackage.test.tsx Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com> * Remove duplicate sentence * Indent note * autofocus -> autoFocus Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
@ -224,4 +224,22 @@ describe("<Excalidraw/>", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Test autoFocus prop", () => {
|
||||
it("should not focus when autoFocus is false", async () => {
|
||||
const { container } = await render(<Excalidraw />);
|
||||
|
||||
expect(
|
||||
container.querySelector(".excalidraw") === document.activeElement,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should focus when autoFocus is true", async () => {
|
||||
const { container } = await render(<Excalidraw autoFocus={true} />);
|
||||
|
||||
expect(
|
||||
container.querySelector(".excalidraw") === document.activeElement,
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user