drag-and-drop
drag-and-drop copied to clipboard
Documentation: Defining `handleEnd` (or any event handler) in the configuration overrides the event handler completely.
I've experienced this with other handlers, but most recently with handleEnd. I have a handleEnd function that does nothing but console.log, yet it breaks expected behavior on touch devices. Likely due to an event getting canceled when the callback is fired.
Repro: https://codesandbox.io/p/sandbox/fk-drag-touch-repro-forked-fy4pz9?file=%2Fpackage.json%3A12%2C38
Video:
https://github.com/formkit/drag-and-drop/assets/13283469/17074301-0a62-49d1-a150-90ab849f60d1
@wesharper Ah yes, when you define handleEnd, you are actually overriding the core event handler itself. The idea is to import the original handleEnd and reinvoke it before or after whatever logic you are trying to add on: sandbox. We plan in the future to implement events you can listen to instead of needing to override the handler itself. Probably would be worth adding an example of this to the docs as other people have been confused by this as well.
Ah, makes sense. Thanks for the feedback. Perhaps there could be an onEnd or onHookName pattern that doesn't override default behavior but acts more as a way to fire off your own logic?
@wesharper Ah yes, when you define
handleEnd, you are actually overriding the core event handler itself. The idea is to import the originalhandleEndand reinvoke it before or after whatever logic you are trying to add on: sandbox. We plan in the future to implement events you can listen to instead of needing to override the handler itself. Probably would be worth adding an example of this to the docs as other people have been confused by this as well.
Thanks for mentioning this @sashamilenkovic, I ran into a similar issue with performTransfer as specifying it caused the default transfer functionality to break, which was unexpected. Event handlers / listeners would be a much better solution or this needs to be more widely documented as myself and others are wasting a lot of time figuring this out