refactor: refs #8683 enhance sorting logic in VnSelect component
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Benjamin Esteve 2025-02-28 13:44:14 +01:00
parent c8e2df41fd
commit a07afe3a94
1 changed files with 5 additions and 1 deletions

View File

@ -152,6 +152,10 @@ const value = computed({
}, },
}); });
const computedSortBy = computed(() => {
return $props.sortBy || $props.optionLabel;
});
watch(options, (newValue) => { watch(options, (newValue) => {
setOptions(newValue); setOptions(newValue);
}); });
@ -186,7 +190,7 @@ function findKeyInOptions() {
} }
function setOptions(data) { function setOptions(data) {
data = dataByOrder(data, $props.sortBy); data = dataByOrder(data, computedSortBy.value);
myOptions.value = JSON.parse(JSON.stringify(data)); myOptions.value = JSON.parse(JSON.stringify(data));
myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
emit('update:options', data); emit('update:options', data);