@@ -50,7 +50,7 @@ import { ITimePickerResourceStrings } from '../core/i18n/time-picker-resources';
5050import { CurrentResourceStrings } from '../core/i18n/resources' ;
5151import { KEYS , CancelableBrowserEventArgs , IBaseEventArgs } from '../core/utils' ;
5252import { InteractionMode } from '../core/enums' ;
53- import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive' ;
53+ import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive' ;
5454
5555let NEXT_ID = 0 ;
5656const ITEMS_COUNT = 7 ;
@@ -1894,9 +1894,12 @@ export class IgxTimePickerComponent implements
18941894 this . isNotEmpty = false ;
18951895
18961896 const oldVal = new Date ( this . value ) ;
1897-
1898- this . displayValue = '' ;
1899- this . value . setHours ( 0 , 0 ) ;
1897+ this . displayValue = this . parseMask ( false ) ;
1898+ requestAnimationFrame ( ( ) => {
1899+ this . _setCursorPosition ( 0 ) ;
1900+ } ) ;
1901+ // TODO: refactoring - this.value should be null #6585
1902+ this . value ?. setHours ( 0 , 0 , 0 ) ;
19001903
19011904 if ( oldVal . getTime ( ) !== this . value . getTime ( ) ) {
19021905 const args : IgxTimePickerValueChangedEventArgs = {
@@ -1914,35 +1917,35 @@ export class IgxTimePickerComponent implements
19141917 * @hidden
19151918 */
19161919 public onInput ( event ) : void {
1917- const val = event . target . value ;
1920+ const inputMask : string = event . target . value ;
19181921 const oldVal = new Date ( this . value ) ;
19191922
1920- this . isNotEmpty = val !== this . parseMask ( false ) ;
1923+ this . isNotEmpty = inputMask !== this . parseMask ( false ) ;
19211924
19221925 // handle cases where all empty positions (promts) are filled and we want to update
19231926 // timepicker own value property if it is a valid Date
1924- if ( val . indexOf ( this . promptChar ) === - 1 ) {
1925- if ( this . _isEntryValid ( val ) ) {
1926- const newVal = this . _convertMinMaxValue ( val ) ;
1927+ if ( inputMask . indexOf ( this . promptChar ) === - 1 ) {
1928+ if ( this . _isEntryValid ( inputMask ) ) {
1929+ const newVal = this . _convertMinMaxValue ( inputMask ) ;
19271930 if ( oldVal . getTime ( ) !== newVal . getTime ( ) ) {
19281931 this . value = newVal ;
19291932 }
19301933 } else {
19311934 const args : IgxTimePickerValidationFailedEventArgs = {
19321935 timePicker : this ,
1933- currentValue : val ,
1936+ currentValue : new Date ( inputMask ) ,
19341937 setThroughUI : false
19351938 } ;
19361939 this . onValidationFailed . emit ( args ) ;
19371940 }
19381941 // handle cases where the user deletes the display value (when pressing backspace or delete)
1939- } else if ( ! this . value || ! val || val === this . parseMask ( false ) ) {
1942+ } else if ( ! this . value || inputMask . length === 0 || ! this . isNotEmpty ) {
19401943 this . isNotEmpty = false ;
1941-
1942- this . value . setHours ( 0 , 0 ) ;
1943- this . displayValue = val ;
1944-
1945- if ( oldVal . getTime ( ) !== this . value . getTime ( ) ) {
1944+ // TODO: refactoring - this.value should be null #6585
1945+ this . value ? .setHours ( 0 , 0 , 0 ) ;
1946+ this . displayValue = inputMask ;
1947+ if ( oldVal . getTime ( ) !== this . value ?. getTime ( ) ) {
1948+ // TODO: Do not emit event when the editor is empty #6482
19461949 const args : IgxTimePickerValueChangedEventArgs = {
19471950 oldValue : oldVal ,
19481951 newValue : this . value
@@ -1969,7 +1972,7 @@ export class IgxTimePickerComponent implements
19691972 this . isNotEmpty = value !== '' ;
19701973 this . displayValue = value ;
19711974
1972- if ( value && value !== this . parseMask ( ) ) {
1975+ if ( value && ( value !== this . parseMask ( ) || value !== this . parseMask ( false ) ) ) {
19731976 if ( this . _isEntryValid ( value ) ) {
19741977 const newVal = this . _convertMinMaxValue ( value ) ;
19751978 if ( ! this . value || this . value . getTime ( ) !== newVal . getTime ( ) ) {
0 commit comments