@@ -159,6 +159,9 @@ export default {
159
159
data .end_ = moment (this .endDate );
160
160
data .hoverStart_ = moment (this .startDate );
161
161
data .hoverEnd_ = moment (this .endDate );
162
+ // fix #14
163
+ data .cloneStart = moment (this .startDate );
164
+ data .cloneEnd = moment (this .endDate );
162
165
163
166
data .startText = moment (this .startDate ).format (data .locale .format );
164
167
data .endText = moment (this .endDate ).format (data .locale .format );
@@ -245,7 +248,19 @@ export default {
245
248
},
246
249
clickApply () {
247
250
this .pickerVisible = false ;
251
+
252
+ // fix #14
253
+ // if the use only click the picker only one time,
254
+ // then close the picker directly(by clickoutside or click the activator)
255
+ if (this .isFirstClick ) {
256
+ this .isFirstClick = false ;
257
+ this .start_ = this .cloneStart .clone ();
258
+ this .end_ = this .cloneEnd .clone ();
259
+ return ;
260
+ }
261
+
248
262
this .updateTextField ();
263
+ this .cloneForCancelUsage ();
249
264
this .emitChange ();
250
265
},
251
266
clickPreset (preset ) {
@@ -273,6 +288,20 @@ export default {
273
288
this .startText = this .start_ .format (this .locale .format );
274
289
this .endText = this .end_ .format (this .locale .format );
275
290
},
291
+ /**
292
+ * fix #14
293
+ * clone start and end for the following scenes, mainly for reseting the selected date to origin state:
294
+ * 1. (autoApply: false) click start [or both start and end], but click the cancel button
295
+ * 2. (autoApply: true) just click one time, and then click outside
296
+ *
297
+ * TODO (need discussion) maybe we can do this action in watch pickerVisible (from hidden to visible)
298
+ * DONE we also need to do clone start and end in the watcher of ther related prop
299
+ *
300
+ */
301
+ cloneForCancelUsage () {
302
+ this .cloneStart = this .start_ .clone ();
303
+ this .cloneEnd = this .end_ .clone ();
304
+ },
276
305
emitChange () {
277
306
const start = this .start_ .clone ();
278
307
const end = this .end_ .clone ();
@@ -313,10 +342,12 @@ export default {
313
342
startDate (value ) {
314
343
this .start_ = moment (value);
315
344
this .startText = moment (value).format (this .locale .format );
345
+ this .cloneStart = moment (value); // fix #14
316
346
},
317
347
endDate (value ) {
318
348
this .end_ = moment (value);
319
349
this .endText = moment (value).format (this .locale .format );
350
+ this .cloneEnd = moment (value); // fix #14
320
351
// TODO not linked calendar
321
352
},
322
353
},
0 commit comments