From 30f584eabb4dd359b02cf843306c8e8e1ea158a8 Mon Sep 17 00:00:00 2001 From: Joe Pavitt Date: Thu, 7 Sep 2023 15:02:13 +0100 Subject: [PATCH] Only emit the "value" when dropdown selection is changed --- ui/src/widgets/ui-dropdown/UIDropdown.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/src/widgets/ui-dropdown/UIDropdown.vue b/ui/src/widgets/ui-dropdown/UIDropdown.vue index 9ecc71171..01867760a 100644 --- a/ui/src/widgets/ui-dropdown/UIDropdown.vue +++ b/ui/src/widgets/ui-dropdown/UIDropdown.vue @@ -87,9 +87,20 @@ export default { onChange () { // ensure our data binding with vuex store is updated const msg = this.messages[this.id] || {} - msg.payload = this.value + if (this.props.multiple) { + // return an array + msg.payload = this.value.map((option) => { + return option.value + }) + } else if (this.value) { + // return a single value + msg.payload = this.value.value + } else { + // return null + msg.payload = null + } this.$store.commit('data/bind', msg) - this.$socket.emit('widget-change', this.id, this.value) + this.$socket.emit('widget-change', this.id, msg.payload) } } }