diff --git a/packages/renderless/src/time-spinner/index.ts b/packages/renderless/src/time-spinner/index.ts index ffbe780e2..bd64744c6 100644 --- a/packages/renderless/src/time-spinner/index.ts +++ b/packages/renderless/src/time-spinner/index.ts @@ -48,6 +48,9 @@ export const decrease = export const modifyDateField = ({ emit, props, state }) => (type, value) => { + if (state[type] === value) { + return + } switch (type) { case 'hours': emit('change', modifyTime(props.date, value, state.minutes, state.seconds)) diff --git a/packages/renderless/src/time-spinner/vue.ts b/packages/renderless/src/time-spinner/vue.ts index b4d8ca219..9aa696334 100644 --- a/packages/renderless/src/time-spinner/vue.ts +++ b/packages/renderless/src/time-spinner/vue.ts @@ -78,7 +78,7 @@ const initState = ({ reactive, computed, props, api }) => { return state } -export const renderless = (props, { computed, onMounted, reactive, watch }, { emit, vm, constants }) => { +export const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, { emit, vm, constants }) => { const api = {} const state = initState({ reactive, computed, props, api }) @@ -108,13 +108,14 @@ export const renderless = (props, { computed, onMounted, reactive, watch }, { em }) watch( - () => props.date.getTime(), + () => props.date, () => { const timeType = ['hours', 'minutes', 'seconds'] timeType.forEach((type) => { api.modifyDateField(type, Math.round(state[type] / state.step[type]) * state.step[type]) }) + nextTick(api.adjustSpinners) }, { immediate: true } )