Skip to content

Commit

Permalink
Fix#4374/allow-more-types-for-select-clear-value (#4375)
Browse files Browse the repository at this point in the history
* fix(tree-view): react on expanded prop for nested children

* fix(#4374): allow more types for clear value prop
  • Loading branch information
m0ksem committed Oct 17, 2024
1 parent 8c5d061 commit de22bc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/ui/src/components/va-select/VaSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ const props = defineProps({
ariaClearLabel: useTranslationProp('$t:reset'),
search: { type: String, default: undefined },
// useClearableProps override
clearValue: { type: [String, Number, Array, Object, Boolean] as PropType<SelectOption | SelectOption[]>, default: '' },
})
const emit = defineEmits([
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/components/va-select/hooks/useStringValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const useStringValueProps = {
separator: { type: String, default: ', ' },
}

type UseStringValueProps = ExtractPropTypes<typeof useStringValueProps> & { clearValue: string }
type UseStringValueProps = ExtractPropTypes<typeof useStringValueProps>

export const useStringValue = (
props: UseStringValueProps,
Expand All @@ -15,9 +15,9 @@ export const useStringValue = (
) => {
return computed<string>(() => {
if (!visibleSelectedOptions.value?.length) {
return props.clearValue
return ''
}

return visibleSelectedOptions.value.map(getText).join(props.separator) || props.clearValue
return visibleSelectedOptions.value.map(getText).join(props.separator) ?? ''
})
}

0 comments on commit de22bc1

Please sign in to comment.