@@ -253,9 +253,10 @@ export class Timepicker extends Component<TimepickerOptions> {
253
253
this . el . addEventListener ( 'keydown' , this . _handleInputKeydown ) ;
254
254
this . plate . addEventListener ( 'mousedown' , this . _handleClockClickStart ) ;
255
255
this . plate . addEventListener ( 'touchstart' , this . _handleClockClickStart ) ;
256
- this . digitalClock . addEventListener ( 'keyup' , this . _inputFromTextField ) ;
257
- this . inputHours . addEventListener ( 'click' , ( ) => this . showView ( 'hours' ) ) ;
258
- this . inputMinutes . addEventListener ( 'click' , ( ) => this . showView ( 'minutes' ) ) ;
256
+ this . digitalClock . addEventListener ( 'change' , this . _inputFromTextField ) ;
257
+ this . inputHours . addEventListener ( 'focus' , ( ) => this . showView ( 'hours' ) ) ;
258
+ this . inputMinutes . addEventListener ( 'focus' , ( ) => this . showView ( 'minutes' ) ) ;
259
+ this . inputMinutes . addEventListener ( 'focusout' , ( ) => this . formatMinutes ( ) ) ;
259
260
}
260
261
261
262
_removeEventHandlers ( ) {
@@ -567,7 +568,7 @@ export class Timepicker extends Component<TimepickerOptions> {
567
568
this . hours = + value [ 0 ] || 0 ;
568
569
this . minutes = + value [ 1 ] || 0 ;
569
570
this . inputHours . value = this . hours ;
570
- this . inputMinutes . value = Timepicker . _addLeadingZero ( this . minutes ) ;
571
+ this . inputMinutes . value = this . minutes ;
571
572
572
573
this . _updateAmPmView ( ) ;
573
574
}
@@ -639,9 +640,7 @@ export class Timepicker extends Component<TimepickerOptions> {
639
640
const value = parseInt ( this . inputHours . value ) ;
640
641
if ( value > 0 && value < 13 ) {
641
642
this . drawClockFromTimeInput ( value , isHours ) ;
642
- this . showView ( 'minutes' , this . options . duration / 2 ) ;
643
643
this . hours = value ;
644
- this . inputMinutes . focus ( ) ;
645
644
}
646
645
else {
647
646
const hour = new Date ( ) . getHours ( ) ;
@@ -651,10 +650,9 @@ export class Timepicker extends Component<TimepickerOptions> {
651
650
else {
652
651
const value = parseInt ( this . inputMinutes . value ) ;
653
652
if ( value >= 0 && value < 60 ) {
654
- this . inputMinutes . value = Timepicker . _addLeadingZero ( value ) ;
653
+ this . inputMinutes . value = String ( value ) ;
655
654
this . drawClockFromTimeInput ( value , isHours ) ;
656
655
this . minutes = value ;
657
- ( < HTMLElement > this . modalEl . querySelector ( '.confirmation-btns :nth-child(2)' ) ) . focus ( ) ;
658
656
}
659
657
else {
660
658
const minutes = new Date ( ) . getMinutes ( ) ;
@@ -759,6 +757,10 @@ export class Timepicker extends Component<TimepickerOptions> {
759
757
this . bg . setAttribute ( 'cy' , cy2 . toString ( ) ) ;
760
758
}
761
759
760
+ formatMinutes ( ) {
761
+ this . inputMinutes . value = Timepicker . _addLeadingZero ( Number ( this . inputMinutes . value ) ) ;
762
+ }
763
+
762
764
/**
763
765
* Open timepicker.
764
766
*/
@@ -809,9 +811,9 @@ export class Timepicker extends Component<TimepickerOptions> {
809
811
<div class="timepicker-digital-display">
810
812
<div class="timepicker-text-container">
811
813
<div class="timepicker-display-column">
812
- <input type="text " maxlength="2" autofocus class="timepicker-input-hours text-primary" />
814
+ <input type="number " maxlength="2" autofocus class="timepicker-input-hours text-primary" min="1" max="12" />
813
815
:
814
- <input type="text " maxlength="2" class="timepicker-input-minutes" />
816
+ <input type="number " maxlength="2" class="timepicker-input-minutes" min="0" max="59" />
815
817
</div>
816
818
<div class="timepicker-display-column timepicker-display-am-pm">
817
819
<div class="timepicker-span-am-pm"></div>
0 commit comments