File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -72,20 +72,23 @@ function TextInputWithMask(
7272 value,
7373 mask,
7474 ...rest
75- } : React . ComponentProps < typeof TextInput > & { mask : string } ,
75+ } : React . ComponentProps < typeof TextInput > & { mask : string ; value : string } ,
7676 ref : any
7777) {
7878 const [ controlledValue , setControlledValue ] = React . useState < string > (
7979 value || ''
8080 )
8181
8282 const onInnerChange = ( text : string ) => {
83- const enhancedText = enhanceTextWithMask ( text , mask , controlledValue )
84- setControlledValue ( enhancedText )
85-
8683 if ( text . length === mask . length ) {
8784 onChangeText && onChangeText ( text )
8885 }
86+ setControlledValue ( text )
87+ }
88+
89+ const onInnerBlur = ( ) => {
90+ const enhancedText = enhanceTextWithMask ( value , mask , controlledValue )
91+ setControlledValue ( enhancedText )
8992 }
9093
9194 React . useEffect ( ( ) => {
@@ -98,6 +101,7 @@ function TextInputWithMask(
98101 { ...rest }
99102 value = { controlledValue }
100103 onChangeText = { onInnerChange }
104+ onBlur = { onInnerBlur }
101105 />
102106 )
103107}
You can’t perform that action at this time.
0 commit comments