@@ -15,10 +15,26 @@ export interface TextComponentProps {
1515}
1616
1717class TextComponent extends Component < TextComponentProps > {
18+ private wasMasked : boolean = false ;
19+
1820 handleChange = ( e : unknown , { value } : { value : string | number } ) => {
1921 this . props . handleChange ( this . props . field , value ) ;
2022 } ;
2123
24+ handleFocus = ( e : React . FocusEvent < HTMLInputElement | HTMLTextAreaElement > ) => {
25+ if ( this . props . encrypted && e . target . value === '******' ) {
26+ this . wasMasked = true ;
27+ this . props . handleChange ( this . props . field , '' ) ;
28+ }
29+ } ;
30+
31+ handleBlur = ( e : React . FocusEvent < HTMLInputElement | HTMLTextAreaElement > ) => {
32+ if ( this . props . encrypted && e . target . value === '' && this . wasMasked ) {
33+ this . props . handleChange ( this . props . field , '******' ) ;
34+ this . wasMasked = false ;
35+ }
36+ } ;
37+
2238 render ( ) {
2339 const { id, field, disabled, value, encrypted, ...restProps } = this . props ;
2440 const restSuiProps = excludeControlWrapperProps ( restProps ) ;
@@ -30,6 +46,8 @@ class TextComponent extends Component<TextComponentProps> {
3046 disabled = { disabled && 'dimmed' }
3147 value = { value === null || typeof value === 'undefined' ? '' : value . toString ( ) }
3248 onChange = { this . handleChange }
49+ onFocus = { this . handleFocus }
50+ onBlur = { this . handleBlur }
3351 type = { encrypted ? 'password' : 'text' }
3452 />
3553 ) ;
0 commit comments