Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit 161db8d

Browse files
committed
fix: External update of modelValue not updating the input value (#20)
1 parent cbdd60d commit 161db8d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Vue3DatePicker/Vue3DatePicker.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
</template>
8989

9090
<script lang="ts" setup>
91-
import { computed, DefineComponent, onMounted, onUnmounted, PropType, ref, useSlots } from 'vue';
91+
import { computed, DefineComponent, onMounted, onUnmounted, PropType, ref, toRef, useSlots, watch } from 'vue';
9292
9393
import DatepickerInput from './components/DatepickerInput.vue';
9494
import DatepickerMenu from './components/DatepickerMenu.vue';
@@ -176,6 +176,7 @@
176176
const slots = useSlots();
177177
const isOpen = ref(false);
178178
const valueCleared = ref(false);
179+
const modelValue = toRef(props, 'modelValue');
179180
180181
onMounted(() => {
181182
parseExternalModelValue(props.modelValue);
@@ -199,6 +200,10 @@
199200
const slotList = mapSlots(slots, 'all');
200201
const inputSlots = mapSlots(slots, 'input');
201202
203+
watch(modelValue, () => {
204+
parseExternalModelValue(modelValue.value);
205+
});
206+
202207
const { openOnTop, menuPosition, setMenuPosition, recalculatePosition } = usePosition(props.position, props.uid);
203208
204209
const { internalModelValue, inputValue, parseExternalModelValue, emitModelValue, checkBeforeEmit } =

src/Vue3DatePicker/utils/composition/external-internal-mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const useExternalInternalMapper = (
7373
formatInputValue();
7474
} else {
7575
internalModelValue.value = null;
76+
inputValue.value = '';
7677
}
7778
};
7879

0 commit comments

Comments
 (0)