You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SetupDragIn not working inside the web component #2275
GridStack.setupDragIn not working inside the web component
Tried Gridstack inside the Lit web component, and it's working fine, but the scenario like dragging in the element from the sidebar (https://gridstackjs.com/demo/static.html) does not work inside shadow root.
Utils.getElements internally using document.querySelectorAll, I think to work inside the shadow root, we need to query inside the parent element or give an argument to the method where we should look in the shadow root scenario...
or we could make setupDragIn() take an array of elements | string selector (like other methods) and you can pass the items you need... that may be more flexible in the long run.
Just thought, for Passing the root element as a param I think we can define a better type instead of the Document type currently tested the below snip works fine, but found during debugging inside Util.getElement in some specific condition, we using root.getElementById that might not be available for HTMLElement...
const root: Document = this.querySelector("#widgets-container") as unknown as Document; GridStack.setupDragIn(".newWidget", { appendTo: "parent", helper: "clone" }, root);
good point. Utils.getElements() is supposed to get all elements (by class selector) but is also called for single ID which only works on the document, so signature need to be HTMLElement | Document. I'll change that.
Activity
adumesny commentedon Apr 27, 2023
or we could make
setupDragIn()take an array of elements | string selector (like other methods) and you can pass the items you need... that may be more flexible in the long run.setupDragIn() shadow DOM support
adumesny commentedon Apr 29, 2023
I didn't get to test it, but this should handle it in the next release.
arulselvan commentedon May 3, 2023
thanks @adumesny! upgraded to V8.0.1, and tested, works like a charm :)
adumesny commentedon May 3, 2023
curious, are you passing a list of elements or the virtual DOM parent ?
arulselvan commentedon May 5, 2023
tested both, and I'm passing a list of elements like the below snip...
`const availableWidgets = this.querySelectorAll(".newWidget");
Just thought, for Passing the root element as a param I think we can define a better type instead of the Document type currently tested the below snip works fine, but found during debugging inside Util.getElement in some specific condition, we using root.getElementById that might not be available for HTMLElement...
const root: Document = this.querySelector("#widgets-container") as unknown as Document; GridStack.setupDragIn(".newWidget", { appendTo: "parent", helper: "clone" }, root);adumesny commentedon May 5, 2023
good point.
Utils.getElements()is supposed to get all elements (by class selector) but is also called for single ID which only works on the document, so signature need to be HTMLElement | Document. I'll change that.setupDragIn() signature fix
setupDragIn() signature fix
adumesny commentedon May 6, 2023
fixed the types. don't forget to donate if you find this lib useful!