thisbeyond / solid-dnd

A lightweight, performant, extensible drag and drop toolkit for Solid JS.
https://solid-dnd.com
MIT License
507 stars 35 forks source link

Undefined eventMap[key] when using dragActivators returned from createDraggable #21

Closed martinpengellyphillips closed 2 years ago

martinpengellyphillips commented 2 years ago

When attempting to drag a draggable that has been composed manually using the `draggable.dragActivators' property, an error will occur:

Uncaught TypeError: eventMap[key] is undefined
    key drag-drop-context.jsx:92

This is due to the asHandlers logic renaming a key naively causing a lookup error:

for (let key in eventMap) {
  if (asHandlers) {
    key = `on${key}`;  // <- renaming here
  }
  listeners[key] = (event) => {
    for (const { activator } of eventMap[key]) {  // <- breaks lookup here
      if (anySensorActive()) {
        break;
      }
      activator({ event, draggableId });
    }
  };
}

This doesn't affect usage as a directive, because that does not use the asHandlers form.

martinpengellyphillips commented 2 years ago

Fixed and released in 0.4.0