You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(CDPE-3578) Add trailingButton* props and deprecate trailingIcon
This commit changes what we're doing a little bit with the button functionality in the Input component. We decided to leave the leading icon out of it all together and just add a trailing button. Now, to add a trailing button, users can either define the trailingButtonIcon prop and/or the trailingButtonText with the onClickTrailingButton prop to get the button going. I also added a trailingButtonProps prop so users can pass things like aria-label to the button. Also, trailingIcon is deprecated.
/** @deprecatedOptional icon rendered after input area */
40
40
trailingIcon: PropTypes.string,
41
-
/** Whether or not the icon is rendered as a button */
42
-
iconButton: PropTypes.bool,
41
+
/** Icon for rendered trailing button */
42
+
trailingButtonIcon: PropTypes.string,
43
+
/** Text for rendered trailing button. Can be used with or without trailingButtonIcon*/
44
+
trailingButtonText: PropTypes.string,
43
45
/** Optional additional className */
44
46
className: PropTypes.string,
45
47
/** Optional inline styles */
@@ -48,8 +50,8 @@ const propTypes = {
48
50
inputRef: PropTypes.func,
49
51
/** Change handler. Passed in order: new value, original event. Additionally, other event handlers and and props are propagated to the inner input element for use as needed */
50
52
onChange: PropTypes.func,
51
-
/** Function for button click (use iconButton to make icon clickable) */
52
-
onClickIconButton: PropTypes.func,
53
+
/** Function for trailing button click */
54
+
onClickTrailingButton: PropTypes.func,
53
55
};
54
56
55
57
constdefaultProps={
@@ -61,12 +63,15 @@ const defaultProps = {
61
63
error: false,
62
64
icon: null,
63
65
trailingIcon: null,
66
+
trailingButtonIcon: null,
67
+
trailingButtonText: '',
68
+
trailingButtonProps: {},
64
69
iconButton: false,
65
70
style: {},
66
71
className: '',
67
72
inputRef(){},
68
73
onChange(){},
69
-
onClickIconButton(){},
74
+
onClickTrailingButton(){},
70
75
};
71
76
72
77
/**
@@ -88,26 +93,23 @@ const Input = ({
88
93
error,
89
94
icon,
90
95
trailingIcon,
91
-
iconButton,
96
+
trailingButtonIcon,
97
+
trailingButtonText,
98
+
trailingButtonProps,
92
99
className,
93
100
style,
94
101
inputRef,
95
102
onChange,
96
-
onClickIconButton,
103
+
onClickTrailingButton,
97
104
...otherProps
98
105
})=>{
99
106
constisMultiline=type==='multiline';
100
107
101
108
constElement=isMultiline ? 'textarea' : 'input';
102
109
103
-
constlIcon=iconButton ? (
104
-
<Button
105
-
className="rc-input-icon rc-input-button-icon leading edge"
0 commit comments