Keep keyboard drag targets aligned with movement axis
Quality / quality (ubuntu-latest) (push) Failing after 1s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 16:55:47 +05:30
1 parent ca2fcb4016
commit 6afffe9f08
3 files changed
+37 -2

No files matched your search

@@ -54,6 +54,7 @@ function fixture(overrides: Partial<DndManagerOptions> = {}) {
manager,
announcements,
instances,
move: (code: string) => listeners.dragmove!({ nativeEvent: { code } }),
start: (id: string) => listeners.dragstart!(event(id)),
end: (id: string, target?: { id: string }) => listeners.dragend!({ ...event(id), operation: { ...event(id).operation, target } }),
over: (target: { id?: string; group?: string; index?: number }) => {
@@ -94,6 +95,25 @@ test("late drop resolution cannot clear or announce a newer gesture", async () =
]);
});
test("keyboard candidates stay in the requested geometric row or column", () => {
const f = fixture();
const element = (left: number, top: number, right: number, bottom: number) => ({ getBoundingClientRect: () => ({ left, top, right, bottom }) }) as HTMLElement;
f.manager.registerSortable({ id: "source", group: "a", index: 0, element: element(0, 100, 100, 150) });
f.manager.registerDropZone({ id: "right", group: "b", index: 0, element: element(110, 100, 200, 160) });
f.manager.registerSortable({ id: "above", group: "c", index: 0, element: element(0, 0, 300, 90) });
const source = { id: "source", type: "text" };
f.start("source");
f.move("ArrowRight");
expect(f.instances[1]!.input.accept(source)).toBe(true);
expect(f.instances[2]!.input.accept(source)).toBe(false);
f.move("ArrowUp");
expect(f.instances[1]!.input.accept(source)).toBe(false);
expect(f.instances[2]!.input.accept(source)).toBe(true);
f.start("source");
expect(f.instances[2]!.input.accept(source)).toBe(true);
f.manager.destroy();
});
test("collision candidates exclude overlapping ancestors and invalid destinations before sorting", () => {
const f = fixture({ accept: (_ids, to) => to.group !== "blocked" });
const child = {} as HTMLElement;