From c9008316b5e0f73581a35348ea421ea485a4f0cf Mon Sep 17 00:00:00 2001 From: Nick Coutsos Date: Tue, 14 Dec 2021 18:01:11 -0500 Subject: Fill in any missing key binds with &none --- application/components/keyboard-layout.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/application/components/keyboard-layout.vue b/application/components/keyboard-layout.vue index 3680f7c..48102be 100644 --- a/application/components/keyboard-layout.vue +++ b/application/components/keyboard-layout.vue @@ -8,9 +8,8 @@ :rotation="rotation(key)" :size="size(key)" :label="key.label" - :parsed="keys[i]" - :value="keys[i].value" - :params="keys[i].params" + :value="normalized[i].value" + :params="normalized[i].params" @update="handleUpdateBind(i, $event)" /> @@ -25,6 +24,16 @@ export default { components: { 'key-thing': Key, }, + computed: { + normalized() { + return this.layout.map((_, i) => ( + this.keys[i] || { + value: '&none', + params: [] + } + )) + } + }, methods: { position(key) { const { x, y } = key @@ -40,9 +49,9 @@ export default { }, handleUpdateBind(keyIndex, updatedBinding) { this.$emit('update', [ - ...this.keys.slice(0, keyIndex), + ...this.normalized.slice(0, keyIndex), updatedBinding, - ...this.keys.slice(keyIndex + 1) + ...this.normalized.slice(keyIndex + 1) ]) } } -- cgit v1.2.3