Need help with a b-form-select control in Bootstrap Vue. Trying to execute a function when the value changes, but want the option to cancel the event and keep the original value.
Complicating matters, the select is in a child component while the function is in the parent component.
The child component
public values: any[] = [
{ name: 'default'},
{ name: 'forbidden'},
{ name: 'other option' },
]
<b-form-select :value="property" @change="$emit('onPropertyChange', arguments[0])">
<option v-for="(val, key) in values" :value="val" :key="key">{{val.Name}}</option>
</b-form-select>
The parent component:
this.property = { name: 'default' }
public onPropertyChange(newValue) {
if (newValue.name === 'forbidden') {
// Not changing this.property
} else {
// Changing it
this.property = newValue
}
}
<child :property="property" @onPropertyChange="onPropertyChange"></child>
After selecting 'forbidden' in the select, I notice that the box shows the new value but both properties remain unchanged, which is desired. How do I prevent the select from updating as well?
Bootstrap Vue seems lacking a prevent modifier for change events. Even using the native event leads to the same issue.
Is my approach incorrect?