Skip to content

Commit 68bfa1b

Browse files
committed
minor change
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 4378548 commit 68bfa1b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ui/src/components/widgets/InfiniteScrollSelect.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
- apiParams (Object, optional): Additional parameters passed to the API
4040
- resourceType (String, required): The key in the API response containing the resource array (e.g., 'account')
4141
- optionValueKey (String, optional): Property to use as the value for options (e.g., 'name'). Default is 'id'
42+
- optionLabelFn (Function, optional): Function to generate the label for options. Receives the option object as argument. If provided, takes precedence over optionLabelKey. Preferred over optionLabelKey.
4243
- optionLabelKey (String, optional): Property to use as the label for options (e.g., 'name'). Default is 'name'
4344
- defaultOption (Object, optional): Preselected object to include initially
4445
- showIcon (Boolean, optional): Whether to show icon for the options. Default is true
4546
- defaultIcon (String, optional): Icon to be shown when there is no resource icon for the option. Default is 'cloud-outlined'
46-
- autoSelectFirstOption (Boolean, optional): Whether to automatically select the first option when options are loaded. Default is false
47+
- autoSelectFirstOption (Boolean, optional): Whether to automatically select the first option when options are loaded. Default is false. Works only when there is no preselected value or defaultOption
4748
4849
Events:
4950
- @change-option-value (Function): Emits the selected option value(s) when value(s) changes. Do not use @change as it will give warnings and may not work
@@ -157,7 +158,7 @@ export default {
157158
scrollHandlerAttached: false,
158159
preselectedOptionValue: null,
159160
successiveFetches: 0,
160-
canSelectFirstOption: false
161+
canSelectFirstOption: true
161162
}
162163
},
163164
created () {
@@ -218,7 +219,7 @@ export default {
218219
}).catch(error => {
219220
this.$notifyError(error)
220221
}).finally(() => {
221-
this.canSelectFirstOption = true
222+
this.canSelectFirstOption = false
222223
if (this.successiveFetches === 0) {
223224
this.loading = false
224225
}
@@ -229,7 +230,7 @@ export default {
229230
(Array.isArray(this.preselectedOptionValue) && this.preselectedOptionValue.length === 0) ||
230231
this.successiveFetches >= this.maxSuccessiveFetches) {
231232
this.resetPreselectedOptionValue()
232-
if (!this.canSelectFirstOption && this.autoSelectFirstOption && this.options.length > 0) {
233+
if (this.canSelectFirstOption && this.autoSelectFirstOption && this.options.length > 0) {
233234
this.$nextTick(() => {
234235
this.preselectedOptionValue = this.options[0][this.optionValueKey]
235236
this.onChange(this.preselectedOptionValue)
@@ -256,7 +257,7 @@ export default {
256257
},
257258
addDefaultOptionIfNeeded () {
258259
if (this.defaultOption) {
259-
this.canSelectFirstOption = true
260+
this.canSelectFirstOption = false
260261
this.options.push(this.defaultOption)
261262
}
262263
},

0 commit comments

Comments
 (0)