sortablejs-vue3 icon indicating copy to clipboard operation
sortablejs-vue3 copied to clipboard

Pinia state persistence

Open Josh-Walker-GM opened this issue 3 years ago • 0 comments

Apologies for this issue which seeks guidance more than raises code issues.

I have a list of objects in a Pinia store which I am accessing in the component via the standard storeToRefs(). These objects contain a property order which is used to specify the order within the list.

I first filter this list to remove an entry via a computed property like:

const filteredObjectList = computed({
  get() {
    return objectList.value.filter((obj) => {
      return obj.id != 0;
    })
  },
  set(newList) {
    console.log(newList)
  }
})

I have been able to produce the correct drag and drop behaviour via :list="filteredObjectList" item-key="order" and the list reorders properly. However the state does not seem to persist when the list is hidden and then shown again via a v-if clause. It is worth noting as well that the setter is never called.

Would you be able to provide some guidance on this non-persistence issue?

Josh-Walker-GM avatar Aug 29 '22 21:08 Josh-Walker-GM