Just use an object instead of an array and replace removeTagDialogs[removeTagDialogs.indexOf(tag.id)]
with removeTagDialogs[tag.id]
, in both places.
See it working: https://codepen.io/andrei-gheorghiu/pen/WNxMyMa
CLICK HERE to find out more related problems solutions.