Skip to content

Commit 4b64ef1

Browse files
authored
Merge pull request #436 from ownego/fix-bug/update-duplicate-modal
Update: model value on duplicate modal
2 parents 45d4ccf + 49e4369 commit 4b64ef1

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/components/Tabs/components/Tab/components/DuplicateModal/DuplicateModal.vue

+6-16
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,22 @@ const emits = defineEmits<{
4343
(e: 'close'): void;
4444
(e: 'click-primary-action', value: string): Promise<void>;
4545
(e: 'click-secondary-action'): void;
46-
(e: 'update:modelValue', value: string): void;
4746
}>();
4847
4948
const i18n = useI18n();
5049
const container = ref<HTMLDivElement | null>(null);
51-
const modalValue = ref<string>('');
5250
53-
const model = computed({
54-
get() {
55-
return props.open ? props.name.slice(0, MAX_VIEW_NAME_LENGTH) : '';
56-
},
57-
set(value: string) {
58-
modalValue.value = value;
59-
emits('update:modelValue', value);
60-
},
61-
});
51+
const model = computed(() => props.open ? props.name.slice(0, MAX_VIEW_NAME_LENGTH) : '');
6252
6353
const hasSameNameError = computed(() => props.viewNames?.some(
64-
(viewName) => viewName.trim().toLowerCase() === modalValue.value.trim().toLowerCase(),
54+
(viewName) => viewName.trim().toLowerCase() === model.value.trim().toLowerCase(),
6555
));
6656
6757
const isPrimaryActionDisabled = computed(() => {
6858
return props.isModalLoading ||
6959
hasSameNameError.value ||
70-
!modalValue.value ||
71-
modalValue.value.length > MAX_VIEW_NAME_LENGTH;
60+
!model.value ||
61+
model.value.length > MAX_VIEW_NAME_LENGTH;
7262
});
7363
7464
const primaryAction = computed(() => ({
@@ -88,7 +78,7 @@ const errorMessage = computed(() =>
8878
hasSameNameError.value
8979
? i18n.translate(
9080
'Polaris.Tabs.DuplicateModal.errors.sameName',
91-
{ name: modalValue.value },
81+
{ name: model.value },
9282
)
9383
: undefined,
9484
);
@@ -113,7 +103,7 @@ const handlePrimaryAction = async () => {
113103
return;
114104
}
115105
116-
await emits('click-primary-action', modalValue.value);
106+
await emits('click-primary-action', model.value);
117107
model.value = '';
118108
emits('close');
119109
}

0 commit comments

Comments
 (0)