Attempt to fix displayName undefined error (#3424)

This commit is contained in:
Prospector
2025-03-25 18:04:50 -07:00
committed by GitHub
parent fd2f500038
commit 4508fad588
3 changed files with 22 additions and 10 deletions

View File

@@ -58,7 +58,7 @@
:value="option"
:name="name"
/>
<label :for="`${name}-${index}`">{{ displayName(option) }}</label>
<label :for="`${name}-${index}`">{{ getOptionLabel(option) }}</label>
</div>
</div>
</transition>
@@ -101,10 +101,14 @@ const props = defineProps({
},
displayName: {
type: Function,
default: (option) => option,
default: undefined,
},
})
function getOptionLabel(option) {
return props.displayName?.(option) ?? option
}
const emit = defineEmits(['input', 'change', 'update:modelValue'])
const dropdownVisible = ref(false)
@@ -114,7 +118,7 @@ const dropdown = ref(null)
const optionElements = ref(null)
const selectedOption = computed(() => {
return props.displayName(selectedValue.value) || props.placeholder || 'Select an option'
return getOptionLabel(selectedValue.value) ?? props.placeholder ?? 'Select an option'
})
const radioValue = computed({