Shopify/draggable

Why Sensors trigger events in source container?

hnrq opened this issue · 4 comments

hnrq commented

I'm still playing around with this lib and I saw that SensorEvents are usually triggered in source container and the target itself is set inside the event's details. This causes some errors when trying to use Happy DOM for testing, because target should be set once the event is dispatched and should not be overriden.

However, everything breaks when triggering Sensor Events on the target itself instead of the container and I'd like to do this replacement here, because it feels like it's the right pattern imo. Any ideas for making this replacement?

Which replacement not work? I try to replace one, it's work because we listen events on document.

hnrq commented

Hmmm. That's probably because you kept this line. I was thinking about also removing these targets that are being passed to the Event itself

It seems we need to check all sensorEvent.target and related logic to achieve this replacement. Like zjffun@6cf6e81

Mainly need to check the logic of source element and original element. See #242
image