mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: adding to selection via shift box-select (#6815)
This commit is contained in:
parent
cbd908097f
commit
8af9ea3cf3
2 changed files with 108 additions and 29 deletions
|
@ -28,6 +28,74 @@ const { h } = window;
|
|||
|
||||
const mouse = new Pointer("mouse");
|
||||
|
||||
describe("box-selection", () => {
|
||||
beforeEach(async () => {
|
||||
await render(<ExcalidrawApp />);
|
||||
});
|
||||
|
||||
it("should allow adding to selection via box-select when holding shift", async () => {
|
||||
const rect1 = API.createElement({
|
||||
type: "rectangle",
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: "red",
|
||||
fillStyle: "solid",
|
||||
});
|
||||
const rect2 = API.createElement({
|
||||
type: "rectangle",
|
||||
x: 100,
|
||||
y: 0,
|
||||
width: 50,
|
||||
height: 50,
|
||||
});
|
||||
|
||||
h.elements = [rect1, rect2];
|
||||
|
||||
mouse.downAt(175, -20);
|
||||
mouse.moveTo(85, 70);
|
||||
mouse.up();
|
||||
|
||||
assertSelectedElements([rect2.id]);
|
||||
|
||||
Keyboard.withModifierKeys({ shift: true }, () => {
|
||||
mouse.downAt(75, -20);
|
||||
mouse.moveTo(-15, 70);
|
||||
mouse.up();
|
||||
});
|
||||
|
||||
assertSelectedElements([rect2.id, rect1.id]);
|
||||
});
|
||||
|
||||
it("should (de)select element when box-selecting over and out while not holding shift", async () => {
|
||||
const rect1 = API.createElement({
|
||||
type: "rectangle",
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: "red",
|
||||
fillStyle: "solid",
|
||||
});
|
||||
|
||||
h.elements = [rect1];
|
||||
|
||||
mouse.downAt(75, -20);
|
||||
mouse.moveTo(-15, 70);
|
||||
|
||||
assertSelectedElements([rect1.id]);
|
||||
|
||||
mouse.moveTo(100, -100);
|
||||
|
||||
assertSelectedElements([]);
|
||||
|
||||
mouse.up();
|
||||
|
||||
assertSelectedElements([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("inner box-selection", () => {
|
||||
beforeEach(async () => {
|
||||
await render(<ExcalidrawApp />);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue