Re: [whatwg/dom] Atomic move operation for element reparenting & reordering (Issue #1255)

> Regarding the pointer capture issue, I want to make sure I understand the scenario. From experimenting [**with this demo I made**](https://output.jsbin.com/moqabap), it seems that moving an element around the DOM (with classic `insertBefore()`, for example) that had `setPointerCapture()` called on it before the move, results in pointer capturing being _reset_ & the `lostpointercapture` event being fired. And it sounds like you'd want it to be preserved, and thus the `lostpointercapture` event would not be fired. Is that right?

Yes, pointer capture itself should stay active and the `lostpointercapture` event should not be fired.
Here is a codepen closer to the issue I was facing: https://codepen.io/Latcarf/pen/NWXjYNb. Try to drag around the "Drag me" rectangle and you'll notice that while it’s easy to drag it to the right, it’s pretty hard to drag it to the left (it keeps getting "stuck"). This is because when swapping two children one has to make a choice which one to remove from the DOM and then reinsert. So if we always remove the one on the right (as React does), pointer capture will be lost only when moving to the left.

I guess that for this special case we could actually check if the element has pointer capture active and in that case do the swap the other way around (`insertBefore(prev, next.nextSibling)` instead of `insertBefore(next, prev)`), but this is not something React does.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1255#issuecomment-2113714755
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1255/2113714755@github.com>

Received on Thursday, 16 May 2024 00:57:40 UTC