Skip to content

Commit

Permalink
feat: clear text displayed on combo-box
Browse files Browse the repository at this point in the history
  • Loading branch information
fterra-encora committed Sep 28, 2023
1 parent aec83fb commit 9636608
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/components/forms/DropdownInputComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ref, computed, watch } from 'vue'
// Carbon
import '@carbon/web-components/es/components/combo-box/index';
import CDSComboBox from '@carbon/web-components/es/components/combo-box/combo-box';
// Composables
import { useEventBus } from '@vueuse/core'
// Types
Expand All @@ -12,6 +13,7 @@ import { isEmpty } from '@/dto/CommonTypesDto'
const props = defineProps<{
id: string
label: string
placeholder?: string
tip: string
modelValue: Array<CodeNameType>
initialValue: string
Expand Down Expand Up @@ -72,6 +74,10 @@ const selectItem = (event:any) => {
//Watch for changes on the input
watch([selectedValue], () => {
if (selectedValue.value === '') {
// force clear text displayed on the combo-box
cdsComboBoxRef.value._filterInputValue = '';
}
validateInput(selectedValue.value)
emitValueChange(selectedValue.value)
})
Expand All @@ -90,15 +96,18 @@ watch(
)
revalidateBus.on(() => validateInput(selectedValue.value))
</script>
const cdsComboBoxRef = ref<InstanceType<typeof CDSComboBox> | null>(null);
</script>

<template>
<div class="grouping-03">
<cds-combo-box
ref="cdsComboBoxRef"
:id="id"
filterable
:helper-text="tip"
:label="placeholder"
:title-text="label"
:value="selectedValue"
:invalid="error ? true : false"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/grouping/AddressGroupComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ onMounted(() => {
label="Country"
:initial-value="selectedValue.country.text"
tip=""
placeholder="Choose an option"
:enabled="true"
:model-value="countryList"
:validations="[...getValidations('location.addresses.country.text'),submissionValidation(`location.addresses[${id}].country`)]"
Expand Down Expand Up @@ -327,6 +328,7 @@ onMounted(() => {
:model-value="content"
:enabled="true"
tip=""
placeholder="Choose an option"
:validations="[...getValidations('location.addresses.*.province.text'),submissionValidation(`location.addresses[${id}].province`)]"
:error-message="addressError"
@update:selected-value="updateStateProvince($event, 'province')"
Expand Down

0 comments on commit 9636608

Please sign in to comment.