From 16f1cb8067a8a1c2be57ac97cbc0165a076ae02a Mon Sep 17 00:00:00 2001 From: Ryan Ludwig Date: Thu, 30 Sep 2021 11:58:36 -0700 Subject: [PATCH] fix(KvCheckbox, KvRadio, KvSwitch): Avoid SSR problems when setting the UUID --- @kiva/kv-components/vue/KvCheckbox.vue | 5 ++++- @kiva/kv-components/vue/KvRadio.vue | 5 ++++- @kiva/kv-components/vue/KvSwitch.vue | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/@kiva/kv-components/vue/KvCheckbox.vue b/@kiva/kv-components/vue/KvCheckbox.vue index 59ff411f..bbf43226 100644 --- a/@kiva/kv-components/vue/KvCheckbox.vue +++ b/@kiva/kv-components/vue/KvCheckbox.vue @@ -96,7 +96,7 @@ export default { }, data() { return { - uuid: `kvc-${nanoid(10)}`, + uuid: '', isChecked: false, }; }, @@ -119,6 +119,9 @@ export default { created() { this.setChecked(); }, + mounted() { + this.uuid = `kvc-${nanoid(10)}`; + }, methods: { onChange(event) { // get the input[type=checkbox] state diff --git a/@kiva/kv-components/vue/KvRadio.vue b/@kiva/kv-components/vue/KvRadio.vue index dd36a2bf..3afca78f 100644 --- a/@kiva/kv-components/vue/KvRadio.vue +++ b/@kiva/kv-components/vue/KvRadio.vue @@ -126,7 +126,7 @@ export default { }, data() { return { - uuid: `kvr-${nanoid(10)}`, + uuid: '', }; }, computed: { @@ -146,6 +146,9 @@ export default { }; }, }, + mounted() { + this.uuid = `kvr-${nanoid(10)}`; + }, methods: { onChange(event) { /** diff --git a/@kiva/kv-components/vue/KvSwitch.vue b/@kiva/kv-components/vue/KvSwitch.vue index 175efeb5..ddf21129 100644 --- a/@kiva/kv-components/vue/KvSwitch.vue +++ b/@kiva/kv-components/vue/KvSwitch.vue @@ -90,7 +90,7 @@ export default { }, data() { return { - uuid: `kvs-${nanoid(10)}`, + uuid: '', }; }, computed: { @@ -104,6 +104,9 @@ export default { }; }, }, + mounted() { + this.uuid = `kvs-${nanoid(10)}`; + }, methods: { onChange(event) { this.$emit('change', event.target.checked);