Skip to content

Commit b2866c4

Browse files
committed
refactor(Timepicker) implemented additional condition to render confirmation container only if auto submit is false; removed timeout since its redundant; fixed incorrect callback option check in cancel callback #570
1 parent 0f9f8bb commit b2866c4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/timepicker.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ export class Timepicker extends Component<TimepickerOptions> {
398398
this.clear
399399
);
400400

401+
if (!this.options.autoSubmit) {
401402
/*const confirmationBtnsContainer = document.createElement('div');
402403
confirmationBtnsContainer.classList.add('confirmation-btns');
403404
this.footer.append(confirmationBtnsContainer);
@@ -411,7 +412,14 @@ export class Timepicker extends Component<TimepickerOptions> {
411412
doneButton.classList.add('timepicker-close');
412413
//doneButton.addEventListener('click', this._finishSelection);
413414
confirmationBtnsContainer.appendChild(doneButton);*/
414-
Utils.createConfirmationContainer(this.footer, this.options.i18n.done, this.options.i18n.cancel, this.confirm, this.cancel);
415+
Utils.createConfirmationContainer(
416+
this.footer,
417+
this.options.i18n.done,
418+
this.options.i18n.cancel,
419+
this.confirm,
420+
this.cancel
421+
);
422+
}
415423

416424
this._updateTimeFromInput();
417425
this.showView('hours');
@@ -794,16 +802,12 @@ export class Timepicker extends Component<TimepickerOptions> {
794802

795803
confirm = () => {
796804
this.done();
797-
if (typeof this.options.onDone === 'function') {
798-
setTimeout(() => {
799-
this.options.onDone.call(this);
800-
}, this.options.duration / 2);
801-
}
805+
if (typeof this.options.onDone === 'function') this.options.onDone.call(this);
802806
}
803807

804808
cancel = () => {
805809
this.clear();
806-
if (typeof this.options.onDone === 'function') this.options.onCancel.call(this);
810+
if (typeof this.options.onCancel === 'function') this.options.onCancel.call(this);
807811
}
808812

809813
clear = () => {

0 commit comments

Comments
 (0)