From 5d37ba109a56cc764c60e0451d383be3fef49833 Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 21 Apr 2021 16:58:31 +0200 Subject: [PATCH] menu/switch/dropdown: reset value to `undefined` when receiving a value that's not defined in `values` --- CHANGELOG.md | 5 ++++- src/client/widgets/basics/menu.js | 12 +++++------- src/client/widgets/basics/switch.js | 13 ++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5495c4f..ac3957b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,10 @@ - bug fixes - button: all writing strings like `"1.0"` in `label` without removing the decimals - - editor: use css variable `--grid-width` at startup (allow overriding) and after disabling & enabling the grid + - editor: use css variable `--grid-width` at startup (allow overriding) and after disabling & enabling the grid + +- widgets + - menu/switch/dropdown: reset value to `undefined` when receiving a value that's not defined in `values` - midi - allow sending note off with velocity diff --git a/src/client/widgets/basics/menu.js b/src/client/widgets/basics/menu.js index 125fad85..125080db 100644 --- a/src/client/widgets/basics/menu.js +++ b/src/client/widgets/basics/menu.js @@ -300,17 +300,15 @@ class Menu extends MenuBase { var i = this.getIndex(v) + this.value = this.values[i] + this.selected = i + DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')}) + this.setLabel() + if (i !== -1) { - this.value = this.values[i] - this.selected = i - DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')}) DOM.get(this.menu, '.item')[i].classList.add('on') - - this.setLabel() - } - if (options.send) this.sendValue() if (options.sync) this.changed(options) diff --git a/src/client/widgets/basics/switch.js b/src/client/widgets/basics/switch.js index 69952bab..34d93e1c 100644 --- a/src/client/widgets/basics/switch.js +++ b/src/client/widgets/basics/switch.js @@ -113,18 +113,17 @@ class Switch extends MenuBase { var i = this.getIndex(v) + this.value = this.values[i] + + DOM.each(this.widget, '.on', (el)=>{el.classList.remove('on')}) if (i !== -1) { - - this.value = this.values[i] - - DOM.each(this.widget, '.on', (el)=>{el.classList.remove('on')}) DOM.get(this.widget, 'value')[i].classList.add('on') - - if (options.send) this.sendValue(this.value) - if (options.sync) this.changed(options) } + if (options.send) this.sendValue(this.value) + if (options.sync) this.changed(options) + } setCssVariables() {