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.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Next
2
2
3
3
-[Copy] Add Copy component (by [@nkanderson](https://github.com/nkanderson) in [#270](https://github.com/puppetlabs/design-system/pull/270))
4
-
-[Input] Add `iconButton`and `onClickIconButton` props for show/hide functionality (by [@eputnam](https://github.com/eputnam) in [#282](https://github.com/puppetlabs/design-system/pull/282))
4
+
-[Input] Add `trailingButtonIcon`, `trailingButtonText`, and `trailingButtonProps` props for show/hide functionality, deprecate `trailingIcon` (by [@eputnam](https://github.com/eputnam) in [#282](https://github.com/puppetlabs/design-system/pull/282))
5
5
-[Form] Use `forwardRef` in Form (by [@caseywilliams](https://github.com/caseywilliams) in [#283](https://github.com/puppetlabs/design-system/pull/283))
6
6
-[Sidebar] Add `containerElement` prop to Sidebar.Item (by [@vine77](https://github.com/vine77) in [#279](https://github.com/puppetlabs/design-system/pull/279))
/** @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,
45
+
/** Additional props for the trailing Button */
46
+
trailingButtonProps: PropTypes.shape({}),
43
47
/** Optional additional className */
44
48
className: PropTypes.string,
45
49
/** Optional inline styles */
@@ -48,8 +52,8 @@ const propTypes = {
48
52
inputRef: PropTypes.func,
49
53
/** 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
54
onChange: PropTypes.func,
51
-
/** Function for button click (use iconButton to make icon clickable) */
52
-
onClickIconButton: PropTypes.func,
55
+
/** Function for trailing button click */
56
+
onClickTrailingButton: PropTypes.func,
53
57
};
54
58
55
59
constdefaultProps={
@@ -61,12 +65,14 @@ const defaultProps = {
61
65
error: false,
62
66
icon: null,
63
67
trailingIcon: null,
64
-
iconButton: false,
68
+
trailingButtonIcon: null,
69
+
trailingButtonText: '',
70
+
trailingButtonProps: {},
65
71
style: {},
66
72
className: '',
67
73
inputRef(){},
68
74
onChange(){},
69
-
onClickIconButton(){},
75
+
onClickTrailingButton(){},
70
76
};
71
77
72
78
/**
@@ -88,26 +94,23 @@ const Input = ({
88
94
error,
89
95
icon,
90
96
trailingIcon,
91
-
iconButton,
97
+
trailingButtonIcon,
98
+
trailingButtonText,
99
+
trailingButtonProps,
92
100
className,
93
101
style,
94
102
inputRef,
95
103
onChange,
96
-
onClickIconButton,
104
+
onClickTrailingButton,
97
105
...otherProps
98
106
})=>{
99
107
constisMultiline=type==='multiline';
100
108
101
109
constElement=isMultiline ? 'textarea' : 'input';
102
110
103
-
constlIcon=iconButton ? (
104
-
<Button
105
-
className="rc-input-icon rc-input-button-icon leading edge"
0 commit comments