Context: I'm making a simple todo app, where you can add & delete items.
Problem: When I click the "Delete" button on a specific item, this happens: it always deletes the last item in the list, instead of the clicked item.
Implementation details: I have a parent & child component. The child component is dinamically rendered with the help of v-for loop, when array gets populated. When button "Delete" is clicked, the child component emits a delete event to parent component. The parent component handles the delete functionality with the "detach()" method.
Code example https://codesandbox.io/s/polished-pine-nnbfo
I'm using splice() method in order to delete the specific component from array and though I'm providing the corect index of component that triggered the delete event, it always deletes the last component from array and I don't know why. Can someone point out the obvious, please ?