Computed property setter does not work propory from template
Version
3.2.33
Steps to reproduce
create a computed property with getter and setter.
getter is getting value from a vmodel in parent component,
setter is modifying the parent vmodel through a emit, from child component.
using setter from template does not give a error, the getter now contains the unmodified value, while the vmodel that it should be getting its value from, remains in the old state,
it seems from template setting the computedValue = value
replaces the whole computedValue with the value and not actually using the setter
while from setup computedValue.value = value
does work as expected..
computedValue.value does not exist within the template,
What is expected?
computed setter should set variable from template
What is actually happening?
computed property is being overwritten with setter value without going through setter logic, creating a new computed property.?? or something like that..??
so how to deal with this..
const { model: value } = makeVmodel(props, emit, "value");
var savedRelations = computed({
get: () => value.value.connectedRelations,
set: (t) => {
const index = value.value.connectedRelations.findIndex(rel => rel.id === t.value.id)
index >= 0 ? value.value.connectedRelations[index] = t.value : value.value.connectedRelations.push(t.value)
}
})
const savedRelationsSetter = (t) => {
savedRelations.value = t
}
@childEmit="(m)=>savedRelations = m"`
nor
@childEmit="savedRelations"
is Not working... while ..
@childEmit="(m)=> savedRelationsSetter(m)"
is working.. im unsure if this is a bug. i can get around it by using a function but this defeats the purpose a bit, as then i could just call the whole thing through a single function setting the vmodel value that way..
Kind Regards
Hello, make sure to always provide a reproduction that follows the instructions at https://new-issue.vuejs.org/?repo=vuejs/vue-next#why-repro.
Remember to use the forum or the Discord chat to ask questions!