Skip to content

Commit 217084a

Browse files
authored
Merge pull request #1068 from Sysvale/hotfix/select-model-value-emission
Hotfix/select model value emission
2 parents 0245ecd + bdee403 commit 217084a

3 files changed

Lines changed: 9 additions & 16 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sysvale/cuida",
3-
"version": "3.154.10",
3+
"version": "3.154.11",
44
"description": "A design system built by Sysvale, using storybook and Vue components",
55
"repository": {
66
"type": "git",

src/components/Select.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,8 @@ watch(localValue, (currentValue) => {
429429
return;
430430
}
431431
432-
if (props.returnValue) {
433-
/**
434-
* Evento que indica que o valor do Select foi alterado
435-
* @event update:modelValue
436-
* @type {Event}
437-
*/
438-
model.value = currentValue[props.optionsField];
439-
} else {
440-
model.value = currentValue;
441-
}
442-
}, { deep: true });
432+
model.value = props.returnValue ? compatibleOptions[0][props.optionsField] : compatibleOptions[0];
433+
});
443434
444435
/* HOOKS */
445436
onMounted(() => {
@@ -551,12 +542,14 @@ function activateSelectionOnClick() {
551542
552543
function hide() {
553544
isSelectingItem = true;
545+
const shouldClearSelection = props.searchable && !props.addable && localOptions.value.length === 0;
554546
555-
if (!searchString.value && !props.addable) {
547+
if (shouldClearSelection) {
556548
model.value = null;
549+
localValue.value = null;
557550
}
558551
559-
if (!searchString.value) {
552+
if (!searchString.value && !shouldClearSelection) {
560553
localValue.value = localOptions.value.some(item => item[props.optionsField]?.toLowerCase() === get(localValue.value, props.optionsField)?.toLowerCase())
561554
? localValue.value
562555
: {};

0 commit comments

Comments
 (0)