@@ -110,9 +110,11 @@ export class NgxMaskDirective
110110 public constructor ( ) {
111111 effect ( ( ) => {
112112 const signalValue = this . value ( ) ;
113- if ( this . _isSignalFormsMode ( ) && signalValue !== untracked ( ( ) => this . _inputValue ( ) ) ) {
113+ if ( this . _isSignalFormsMode ( ) ) {
114114 untracked ( ( ) => {
115- this . writeValue ( signalValue ) ;
115+ if ( String ( signalValue ) !== String ( this . _inputValue ( ) ) ) {
116+ this . writeValue ( signalValue ) ;
117+ }
116118 } ) ;
117119 }
118120 } ) ;
@@ -448,6 +450,7 @@ export class NgxMaskDirective
448450 @HostListener ( 'focus' )
449451 public onFocus ( ) : void {
450452 this . _isFocused . set ( true ) ;
453+ this . _maskService . _isFocused . set ( true ) ;
451454 }
452455
453456 @HostListener ( 'ngModelChange' , [ '$event' ] )
@@ -781,18 +784,22 @@ export class NgxMaskDirective
781784
782785 el . value = el . value . includes ( decimalMarker )
783786 ? el . value +
784- MaskExpression . NUMBER_ZERO . repeat ( precision - decimalPart . length ) +
787+ MaskExpression . NUMBER_ZERO . repeat (
788+ precision - ( decimalPart ?. length || 0 )
789+ ) +
785790 suffix
786791 : el . value +
787792 decimalMarker +
788793 MaskExpression . NUMBER_ZERO . repeat ( precision ) +
789794 suffix ;
790795 this . _maskService . actualValue = el . value ;
796+ this . onChange ( this . _maskService . actualValue ) ;
791797 }
792798 }
793799 this . _maskService . clearIfNotMatchFn ( ) ;
794800 }
795801 this . _isFocused . set ( false ) ;
802+ this . _maskService . _isFocused . set ( false ) ;
796803 this . onTouch ( ) ;
797804 }
798805
@@ -1072,6 +1079,16 @@ export class NgxMaskDirective
10721079 this . _inputValue . set ( inputValue ) ;
10731080 this . _setMask ( ) ;
10741081
1082+ if ( this . _isSignalFormsMode ( ) ) {
1083+ untracked ( ( ) => {
1084+ const stringValue =
1085+ value === null || typeof value === 'undefined' ? '' : String ( value ) ;
1086+ if ( String ( this . value ( ) ) !== stringValue ) {
1087+ this . value . set ( stringValue ) ;
1088+ }
1089+ } ) ;
1090+ }
1091+
10751092 if (
10761093 ( inputValue && this . _maskService . maskExpression ) ||
10771094 ( this . _maskService . maskExpression &&
@@ -1087,11 +1104,18 @@ export class NgxMaskDirective
10871104 // Let the service know we've finished writing value
10881105 this . _maskService . writingValue = false ;
10891106 this . _maskService . isInitialized = true ;
1107+ if ( this . _isSignalFormsMode ( ) ) {
1108+ untracked ( ( ) => {
1109+ const actualValue = this . _maskService . actualValue ;
1110+ if ( String ( this . value ( ) ) !== actualValue ) {
1111+ this . value . set ( actualValue ) ;
1112+ }
1113+ } ) ;
1114+ }
10901115 } else {
10911116 this . _maskService . formElementProperty = [ 'value' , inputValue ] ;
10921117 this . _maskService . isInitialized = true ;
10931118 }
1094- this . _inputValue . set ( inputValue ) ;
10951119 } else {
10961120 // eslint-disable-next-line no-console
10971121 console . warn (
@@ -1110,9 +1134,11 @@ export class NgxMaskDirective
11101134 if ( this . _isSignalFormsMode ( ) ) {
11111135 const stringValue =
11121136 value === null || typeof value === 'undefined' ? '' : String ( value ) ;
1113- if ( this . value ( ) !== stringValue ) {
1114- this . value . set ( stringValue ) ;
1115- }
1137+ untracked ( ( ) => {
1138+ if ( String ( this . value ( ) ) !== stringValue ) {
1139+ this . value . set ( stringValue ) ;
1140+ }
1141+ } ) ;
11161142 }
11171143 } ;
11181144 }
0 commit comments