kutlugsahin / vue-smooth-dnd

Vue wrapper components for smooth-dnd
MIT License
1.73k stars 249 forks source link

select gets reverted to default value on move #229

Open robertplanetweb opened 5 months ago

robertplanetweb commented 5 months ago

select gets reverted to default value on move but gets restored on drop. this is only a visual bug, it doesn't affect the v-model.

here's a workaround:

<script>
....
methods: {
    setSelected(e) {
        setTimeout(() => {
            for ( let option of e.target.querySelectorAll(`option`) ) {
                option.value == this.something ? option.setAttribute('selected', 'selected') : option.removeAttribute('selected');
            }
        }, 10);
    },
},
mounted() {
  this.setSelected({ target: this.$refs.select });
}
.....
</script>

<select v-model="something" ref="select">
     <option value="first_value">First Value</option>
     <option value="second_value">Second Value</option>
</select>

PS: awesome plugin, thanks @kutlugsahin