diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue index 096cbe08..da16f281 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue @@ -115,7 +115,6 @@ export default { return this.modelValue?.partNumber; }, set(newValue) { - console.log(this.selectedPartNumber) this.$emit( "update:modelValue", this.partsForSelectedTint.filter((part) => part.partNumber == newValue.value)[0] @@ -184,40 +183,28 @@ export default { // Also checks if only a single part is present for the tint. ResetTintAndPartSelections() { this.selectedPartNumber = null; - this.AutoSelectIfSinglePart(); + this.AutoSelect(); }, - // Check if only a single part is present for the tint and set the v-model if it is. - AutoSelectIfSinglePart() { + + AutoSelect() { + // Check if only a single part is present for the tint and set the v-model if it is. if (this.partsForSelectedTint?.length == 1) { this.selectedPartNumber = { value: this.partsForSelectedTint[0].partNumber }; - - this.$nextTick(() => { - //select element with matching partNumber - const element = document.querySelector('input[value=' + this.selectedPartNumber + ']').checked = true; - - }); } else{ - if(this.selectedPartNumber && this.partsForSelectedTint.filter(x => x.partNumber == this.selectedPartNumber).length > 0) + // If selected part isn't in the current list or it's null, select the first part + if(!this.selectedPartNumber || this.partsForSelectedTint.filter(x => x.partNumber == this.selectedPartNumber).length === 0) { - this.$nextTick(() => { - //select element with matching partNumber - const element = document.querySelector('input[value=' + this.selectedPartNumber + ']').checked = true; - - }); - } - else{ - this.selectedPartNumber = { value: this.partsForSelectedTint[0].partNumber } - this.$nextTick(() => { - //select element with matching partNumber - const element = document.querySelector('input[value=' + this.selectedPartNumber + ']').checked = true; - - }); + this.selectedPartNumber = { value: this.partsForSelectedTint[0].partNumber }; } } - }, + //select element with matching partNumber + this.$nextTick(() => { + document.querySelector('input[value=' + this.selectedPartNumber + ']').checked = true; + }); + }, // Loads the preselected values from the store. LoadPreselectedValues() { this.$nextTick(() => { @@ -230,7 +217,7 @@ export default { }, watch: { selectedTint() { - this.AutoSelectIfSinglePart(); + this.AutoSelect(); }, }, };