File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
src/components/inputPassword Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -48,22 +48,20 @@ const InputPasswordComponent = React.forwardRef(
48
48
ctv
49
49
) ;
50
50
51
- const icon = inputPasswordType === InputTypeType . PASSWORD ? disabledIcon : activeIcon ;
52
-
53
- const setTypeInput : React . MouseEventHandler < HTMLButtonElement > = event => {
51
+ const handleRightIconClick : React . MouseEventHandler < HTMLButtonElement > = event => {
54
52
const icon = inputPasswordType === InputTypeType . PASSWORD ? disabledIcon : activeIcon ;
55
53
56
54
setInputPasswordType (
57
55
inputPasswordType === InputTypeType . PASSWORD ? InputTypeType . TEXT : InputTypeType . PASSWORD
58
56
) ;
59
57
onInputTypeChange && onInputTypeChange ( ) ;
60
58
// deprecated - Remove this icon.onClick when the 'icon' is removed from the component
61
- icon . onClick ?. (
59
+ const iconClickValue =
62
60
inputPasswordType === InputTypeType . PASSWORD
63
61
? OnIconClickValueType . VISIBLE
64
- : OnIconClickValueType . HIDE ,
65
- event
66
- ) ;
62
+ : OnIconClickValueType . HIDE ;
63
+ icon . onClick ?. ( iconClickValue , event ) ;
64
+ onIconClick ?. ( iconClickValue ) ;
67
65
} ;
68
66
69
67
const {
@@ -94,14 +92,16 @@ const InputPasswordComponent = React.forwardRef(
94
92
onInternalErrors,
95
93
} ) ;
96
94
95
+ const icon = inputPasswordType === InputTypeType . PASSWORD ? disabledIcon : activeIcon ;
96
+
97
97
return (
98
98
< InputPasswordStandAlone
99
99
{ ...props }
100
100
ref = { inputRef }
101
101
maxLength = { maxLength }
102
102
rightIcon = { {
103
103
...icon ,
104
- onClick : event => setTypeInput ( event ) ,
104
+ onClick : handleRightIconClick ,
105
105
} }
106
106
state = { state }
107
107
styles = { styles }
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ const commonArgs: IInputPassword = {
40
40
placeholder : 'Placeholder' ,
41
41
required : true ,
42
42
helpMessage : { content : 'HEEEELP!' } ,
43
- activeIcon : { icon : ICONS . ICON_GHOST , altText : 'Show password' } ,
44
- disabledIcon : { icon : ICONS . ICON_PLACEHOLDER , altText : 'Hide password' } ,
43
+ activeIcon : { icon : ICONS . ICON_GHOST , altText : 'Hide password' } ,
44
+ disabledIcon : { icon : ICONS . ICON_PLACEHOLDER , altText : 'Show password' } ,
45
45
errorMessage : { content : 'Error message' } ,
46
46
errorIcon : { icon : ICONS . ICON_PLACEHOLDER , altText : 'error' } ,
47
47
secondaryLabel : labelSecondary ( themeSelected ) ,
Original file line number Diff line number Diff line change @@ -45,5 +45,8 @@ export interface IInputPassword<V = undefined extends string ? unknown : string>
45
45
onInputTypeChange ?: ( ) => void ;
46
46
onInternalErrors ?: ( errors : string [ ] ) => void ;
47
47
onError ?: ( error : boolean ) => void ;
48
+ /**
49
+ * @deprecated This prop will be deprecated in the next major. Use instead activeIcon onClick and disabledIcon on click
50
+ */
48
51
onIconClick ?: ( value : OnIconClickValueType ) => void ;
49
52
}
You can’t perform that action at this time.
0 commit comments