-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dnd does not work when adding new elements in list #107
Comments
@KuchinaPS Hey there! Are the reactive values you are updating the same values that are bound to the list of items you are iterating over? It's hard to guess without seeing your code; I'd be happy to take a look at a reproduction |
This is a similar implementation. Here, after moving elements in the list, adding new ones stops working. https://codesandbox.io/p/sandbox/eloquent-bird-9x2xgl |
@KuchinaPS In your example, if I use something other than the index to set the key property, it works fine. Here's how I updated your
|
In the example, everything really works fine. Maybe then the problem is in my receiving data from the backend or using the pinia storage. |
@KuchinaPS Yeah, shouldn't need to emit an update on the values that are "drag and dropped". My guess would be that the values you're getting from your pinia store are maybe not reactive/refs? \ |
I am seeing a similar problem. I am using realtime data from firestore that populates a pinia store. const { userData } = storeToRefs(contactsStore)
const groupsParent = ref(null)
dragAndDrop({
parent: groupsParent,
values: userData.value.contactOrder,
dragHandle: '.groupHandle',
onDragend: (event) => {
groupOrderChanged(event.values)
},
onSort: (event) => {
userData.value.contactOrder = event.values
},
})
function groupOrderChanged(values) {
userData.value.contactOrder = values
contactsStore.updateContactOrder()
} However if the data gets changed somewhere else the UI updates but it seems like the event.values don't. |
I have the same error "The number of enabled nodes does not match the number of values." when adding and removing an element. |
I adjusted KuchinaPS's example with a pinia store and the error I am seeing: https://codesandbox.io/p/sandbox/infallible-fog-fsv9zp?workspaceId=c8c26021-4482-4a8e-87a1-ee4197aaa807 As soon as you hit add it breaks. |
@BradDuns Hey there! I took a look at your reproduction (appreciate it!). So, a couple things: 1). In your example, you are using 2). 3). And then just to put a fine point on this, in your code snippet where in your |
It's interesting, for me this causes the data to get wonky and duplicate keys in my project. There must be some other interaction that causes it to lose reactivity when it round trips through Firestore. This uses VueUse but I am using vueFire in my project with the same outcome. |
@BradDuns I'm seeing the same as you are in your reproduction there. I will take a look at it more closely when I have the chance. |
Thanks! I’m not sure, but I wonder if it could be related to using a computed property for a nested object. I thought refs were deeply reactive, and I typically haven’t needed computed properties for this. With vue-draggable I'm passing the top level ref without issue. That said, I really like how much cleaner FormKit makes the template so trying to switch my app over. |
Thanks for your help! My problem was solved by using dragAndDrop and computed for the value from the pinia store. But the values started to duplicate. To avoid this, I used:
|
remap for me didn't fix the issue. @sashamilenkovic have you had time to look at this issue at all? |
@BradDuns Hey there! Apologies for not taking a look sooner, and I appreciate you reminding me. I have taken a look, and have resolved the issue (not deeply checking for equality in my filter function in |
When adding a new element to the draggable list, the new element does not appear in the list, and when refreshing the page, it is not draggable.
How to correctly update the list of draggable elements when adding or removing from it?
I tried updateConfig({}), but nothing worked.
The text was updated successfully, but these errors were encountered: