CSR-1102 Match code to ISS and test flow.

This commit is contained in:
Bryan Mauger 2023-01-27 10:10:43 -05:00
parent f9413dc060
commit c54cf6e4a6

View file

@ -1,5 +1,5 @@
<template>
<div class="dropdown-question" :class="errorMessage || hasError ? 'has-error' : ''">
<div class="dropdown-question" :class="(errors && errors.length) || hasError ? 'has-error' : ''">
<label
:for="inputId"
:aria-label="questionText"
@ -13,7 +13,9 @@
:aria-disabled="isDisabled"
:disabled="isDisabled"
:aria-required="isRequired"
:validationRules="validationRules">
:validationRules="validationRules"
:placeHolderText="placeHolderText">
<option v-if="placeHolderText" value="" selected>{{ placeHolderText }}</option>
<option v-for="(value, name, index) in options" :value="name" :key="index">
{{ value }}
</option>
@ -38,9 +40,11 @@ export default {
},
isDisabled: Boolean,
isRequired: Boolean,
disableAutoFill: Boolean,
validationRules: String,
cmsWidgetName: String,
hasError: Boolean,
placeHolderText: String
},
setup(props) {
const propsClone = Object.assign({}, props);
@ -52,7 +56,7 @@ export default {
initialValue = modelValue;
break;
default:
initialValue = modelValue && modelValue.length > 0 ? modelValue : "";
initialValue = (modelValue && modelValue.length > 0) ? modelValue : "";
break;
}
@ -62,7 +66,7 @@ export default {
initialValue: initialValue,
};
const { errorMessage, handleBlur, handleChange, meta } = useField(
const {errorMessage, handleBlur, handleChange, meta, errors } = useField(
props.inputId,
props.validationRules,
fieldOptions
@ -73,6 +77,7 @@ export default {
handleBlur,
handleChange,
meta,
errors
};
},
computed: {
@ -81,7 +86,7 @@ export default {
},
selectedOption: {
get: function () {
return this.modelValue;
return !this.modelValue ? "" : this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);