mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
feat: switch to selection tool on library item insert (#3773)
* switch to selection tool on library item insert * add test Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
bdead4d164
commit
44402f42bf
2 changed files with 19 additions and 0 deletions
|
@ -1282,6 +1282,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
this.scene.getElements(),
|
this.scene.getElements(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
this.selectShapeTool("selection");
|
||||||
};
|
};
|
||||||
|
|
||||||
private addTextFromPaste(text: any) {
|
private addTextFromPaste(text: any) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import ExcalidrawApp from "../excalidraw-app";
|
||||||
import { API } from "./helpers/api";
|
import { API } from "./helpers/api";
|
||||||
import { MIME_TYPES } from "../constants";
|
import { MIME_TYPES } from "../constants";
|
||||||
import { LibraryItem } from "../types";
|
import { LibraryItem } from "../types";
|
||||||
|
import { UI } from "./helpers/ui";
|
||||||
|
|
||||||
const { h } = window;
|
const { h } = window;
|
||||||
|
|
||||||
|
@ -40,4 +41,21 @@ describe("library", () => {
|
||||||
expect(h.elements).toEqual([expect.objectContaining({ id: "A_copy" })]);
|
expect(h.elements).toEqual([expect.objectContaining({ id: "A_copy" })]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("inserting library item should revert to selection tool", async () => {
|
||||||
|
UI.clickTool("rectangle");
|
||||||
|
expect(h.elements).toEqual([]);
|
||||||
|
const libraryItems: LibraryItem = JSON.parse(
|
||||||
|
await API.readFile("./fixtures/fixture_library.excalidrawlib", "utf8"),
|
||||||
|
).library[0];
|
||||||
|
await API.drop(
|
||||||
|
new Blob([JSON.stringify(libraryItems)], {
|
||||||
|
type: MIME_TYPES.excalidrawlib,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(h.elements).toEqual([expect.objectContaining({ id: "A_copy" })]);
|
||||||
|
});
|
||||||
|
expect(h.state.elementType).toBe("selection");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue