|
46 | 46 | </div> |
47 | 47 | </template> |
48 | 48 | <script setup> |
49 | | -import {ref, computed, onMounted, watch, onBeforeUnmount, nextTick} from 'vue'; |
| 49 | +import {ref, computed, onMounted, watch, onBeforeUnmount} from 'vue'; |
50 | 50 | import dayjs from 'dayjs'; |
51 | 51 | import utc from 'dayjs/plugin/utc'; |
52 | 52 |
|
@@ -89,6 +89,8 @@ const startTime = ref(''); |
89 | 89 |
|
90 | 90 | const datepickerObject = ref('') |
91 | 91 |
|
| 92 | +let datepickerReady; |
| 93 | +
|
92 | 94 | const start = computed(() => { |
93 | 95 | if (props.column?.type === 'time') { |
94 | 96 | return formatTime(startTime.value); |
@@ -118,14 +120,15 @@ async function updateFromProps() { |
118 | 120 | } else if (props.column.type === 'time') { |
119 | 121 | startTime.value = props.valueStart; |
120 | 122 | } else { |
121 | | - // wait ref to initialize |
122 | | - await nextTick(); |
| 123 | + // datepicker is created only after its lazy-loaded chunk resolves |
| 124 | + await datepickerReady; |
123 | 125 | datepickerObject.value.setDate(dayjs(props.valueStart).format('DD MMM YYYY')); |
124 | 126 | startTime.value = dayjs(props.valueStart).format('HH:mm:ss') |
125 | 127 | } |
126 | 128 | } |
127 | 129 |
|
128 | 130 | onMounted(() => { |
| 131 | + datepickerReady = initDatepickers(); |
129 | 132 | updateFromProps(); |
130 | 133 |
|
131 | 134 | watch(() => [props.valueStart], (value) => { |
@@ -183,10 +186,6 @@ const toggleTimeInputs = () => { |
183 | 186 | showTimeInputs.value = !showTimeInputs.value |
184 | 187 | } |
185 | 188 |
|
186 | | -onMounted(() => { |
187 | | - initDatepickers(); |
188 | | -}); |
189 | | -
|
190 | 189 | onBeforeUnmount(() => { |
191 | 190 | removeChangeDateListener(); |
192 | 191 | destroyDatepickerElement(); |
|
0 commit comments