From a07afe3a94bc7e1911576a1fc6f2ce2bf7cdc4c6 Mon Sep 17 00:00:00 2001 From: benjaminedc Date: Fri, 28 Feb 2025 13:44:14 +0100 Subject: [PATCH] refactor: refs #8683 enhance sorting logic in VnSelect component --- src/components/common/VnSelect.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index d111780bd..eb387fe61 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -152,6 +152,10 @@ const value = computed({ }, }); +const computedSortBy = computed(() => { + return $props.sortBy || $props.optionLabel; +}); + watch(options, (newValue) => { setOptions(newValue); }); @@ -186,7 +190,7 @@ function findKeyInOptions() { } function setOptions(data) { - data = dataByOrder(data, $props.sortBy); + data = dataByOrder(data, computedSortBy.value); myOptions.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); emit('update:options', data);