Skip to content

Commit 30c2832

Browse files
committed
refactor: move watch modelValueLocal into setModelValueLocal
1 parent bbd4786 commit 30c2832

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/vue-final-modal/src/components/CoreModal/useModelValue.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ export function useModelValue(
2828
*/
2929
function setModelValueLocal(val: boolean) {
3030
const success = val ? open() : close()
31-
if (success)
31+
if (success) {
3232
_modelValueLocal.value = val
33-
else
33+
if (val !== props.modelValue)
34+
emit('update:modelValue', val)
35+
}
36+
else {
3437
emit('update:modelValue', !val)
38+
}
3539
}
3640

3741
watch(() => props.modelValue, (val) => {
3842
modelValueLocal.value = !!val
3943
})
40-
watch(modelValueLocal, (val) => {
41-
if (val !== props.modelValue)
42-
emit('update:modelValue', val)
43-
})
4444

4545
return {
4646
modelValueLocal,

0 commit comments

Comments
 (0)