fix(dnd): validate proposed hover destinations
This commit is contained in:
1 parent
c1f4f42b21
commit
8bc8fe85c3
5 files changed
+42
-3
No files matched your search
@@ -55,6 +55,17 @@ function fixture(overrides: Partial<DndManagerOptions> = {}) {
|
||||
instances,
|
||||
start: (id: string) => listeners.dragstart!(event(id)),
|
||||
end: (id: string) => listeners.dragend!(event(id)),
|
||||
over: (target: { group: string; index: number }) => {
|
||||
let prevented = false;
|
||||
listeners.dragover!({
|
||||
...event("first"),
|
||||
operation: { ...event("first").operation, target },
|
||||
preventDefault: () => {
|
||||
prevented = true;
|
||||
},
|
||||
});
|
||||
return prevented;
|
||||
},
|
||||
get managerDestructions() {
|
||||
return managerDestructions;
|
||||
},
|
||||
@@ -82,6 +93,14 @@ test("late drop resolution cannot clear or announce a newer gesture", async () =
|
||||
]);
|
||||
});
|
||||
|
||||
test("hover acceptance checks the proposed target instead of the source's old group", () => {
|
||||
const f = fixture({ accept: (_ids, to) => to.group === "allowed" });
|
||||
f.start("first");
|
||||
expect(f.over({ group: "blocked", index: 2 })).toBe(true);
|
||||
expect(f.announcements.at(-1)?.location).toEqual({ group: "blocked", index: 2 });
|
||||
expect(f.over({ group: "allowed", index: 0 })).toBe(false);
|
||||
});
|
||||
|
||||
test("drop commit rejection reports cancellation and its original intent", async () => {
|
||||
const failure = new Error("save failed");
|
||||
const errors: unknown[] = [];
|
||||
|
||||
Reference in new issue
Block a user