Skip to content

Commit 4be7c5f

Browse files
committed
- Fix LocationAddressPicker reliance on values that are never falsy preventing clear
1 parent 17dc452 commit 4be7c5f

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

Rock.JavaScript.Obsidian/Framework/Controls/locationAddressPicker.obs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ContentDropDownPicker v-bind="formFieldProps"
44
:modelValue="pickerValue"
55
iconCssClass="ti ti-map-pin"
6-
:showClear="!!pickerValue"
6+
:showClear="!isPickerEmpty"
77
@primaryButtonClicked="select"
88
@secondaryButtonClicked="cancel"
99
@clearButtonClicked="clear"
@@ -77,9 +77,11 @@
7777
const controlValue = ref({});
7878

7979
// This Picker
80-
const pickerValue = ref({});
80+
const pickerValue = ref<AddressControlBag>(getEmptyAddressControlBag());
8181
const pickerLabel = ref("");
82+
8283
const errors = ref<FormError[]>([]);
84+
8385
const isLoading = ref(false);
8486
const internalShowPopup = useVModelPassthrough(props, "showPopup", emit);
8587

@@ -89,12 +91,35 @@
8991

9092
// #region Computed Values
9193

94+
const isPickerEmpty = computed(() => {
95+
return !pickerValue.value.street1
96+
&& !pickerValue.value.city
97+
&& !pickerValue.value.state
98+
&& !pickerValue.value.postalCode
99+
&& !pickerValue.value.country;
100+
});
101+
92102
const isRequired = computed(() => {
93103
return containsRequiredRule(props.rules);
94104
});
95105

96106
// #endregion
97107

108+
// #region Functions
109+
110+
function getEmptyAddressControlBag(): AddressControlBag {
111+
return {
112+
street1: "",
113+
street2: "",
114+
city: "",
115+
state: "",
116+
postalCode: "",
117+
country: ""
118+
};
119+
}
120+
121+
// #endregion Functions
122+
98123
// #region Event Handlers
99124

100125
async function select(): Promise<void> {
@@ -126,7 +151,7 @@
126151
}
127152

128153
function clear(): void {
129-
pickerValue.value = {};
154+
pickerValue.value = getEmptyAddressControlBag();
130155
pickerLabel.value = "";
131156
}
132157

0 commit comments

Comments
 (0)