colinrobertbrooks / react-beautiful-dnd-test-utils

Test utils for react-beautiful-dnd built with react-testing-library 🧤
https://www.npmjs.com/package/react-beautiful-dnd-test-utils
MIT License
32 stars 14 forks source link

Move outside of Droppable area #17

Closed Dalez closed 2 years ago

Dalez commented 2 years ago

Hey, thanks for the handy package!

I was wondering if there was a way to request that an item be dropped outside of a destination, so that we can cover this bit of code:

    if (!result.destination) {
      return;
    }

Currently I'm having to ignore this bit of code in our coverage, as I can't see a way to move an item outside of the droppable area, like you can with a mouse. Maybe something like this:

    await makeDnd({
      getDragElement: (): Element => screen.getByText("item").closest(DND_DRAGGABLE_DATA_ATTR),
      direction: DND_OUTSIDE_DROP_AREA,
      positions: 0
    });

Thanks! :)

colinrobertbrooks commented 2 years ago

Underneath the hood this package uses react-beautiful-dnd's keyboard dragging, and its directions correspond to special characters from user-event. With these APIs as they are I don't think there's a good way to drop outside of a destination, but am happy to revisit this if a potential solution arises in the future.