-
Notifications
You must be signed in to change notification settings - Fork 27
(CDPE-3578) Add show/hide capabilities for <Input> #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
definitely open to thoughts on the api here. these two props (iconButton and onClickIconButton) make it probably as flexible as possible but the thought also occurred to me that we maybe don't want that. what other functions do we image the button having? would it make sense to just have a |
Hey @eputnam I definitely see your concern with the API. In this particular case a consumer could potentially add a leading AND trailing button. Currently, if the consumer also provided the onClickIconButton the function would be fired on both elements potentially leading to confusion. Do you know if there have been any cases where folks wanted both leading and trailing icons? |
Hey Eric. Been reviewing this with Geoff and thinking about other use cases without making this too complex. A few thoughts:
|
Another thought. If the trailing side is reserved for actions then we should plan to deprecate the trailing icon prop. |
@Sigler , @woodburndesigns , thanks for the reviews! So how bout this: (cc: @vine77 )
|
Sounds good to me! Lets go for it for now @eputnam |
Looks good. On your 4th point, we can add an info section about trailingIcons being deprecated in 2.0. We should also emphasize it in the notes and communicate it in the slack channel. I'm not sure how to best implement it, but it would be nice to be able to pull up a list of everything to be deprecated in 2.0 that we can communicate when we get closer to launch. |
value={state['input-ex13-value']} | ||
trailingIcon="eye" | ||
placeholder="We will eventually use this for a masked input" | ||
iconButton | ||
placeholder="Use the trailing icon for showing/hiding passwords" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the button be provided with an aria-label
attribute to provide an accessible name for the button? Placeholder is not reliably announced by assistive technology.
7e56cc2
to
f907c01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for the updates.
Currently, the trailing and leading icons on the Input component are only icons. This commit makes changes to the Input component api to allow a callback to be passed to the icon to facilitate a password show/hide for example. This includes a boolean to turn the icon into a button and then a prop so that the consumer can pass an onClick to the button.
I was having trouble with CSS inheritence and honestly its probably not right still, but I was able to make the leading icon sit all the way to the left finally. This change also adds to the Input.md and adds a CHANGELOG entry for these changes as per CONTRIBUTING.md
This adds a basic basic test to make sure the icon is wrapped in a button and the button receives a click with the correct props
The linter doesn't like the 'none' value for getting rid of the border on the leading/trailing button, so i tried hidden instead and it was fine. Yey. This is probably one of many css conventions I'm not familiar with.
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.
f907c01
to
fd1f670
Compare
(CDPE-3578) Add api for show/hide to
Currently, the trailing and leading icons on the Input component are only icons. This commit makes changes to the Input component api to allow a callback to be passed to the icon to facilitate a password show/hide for example. This includes a boolean to turn the icon into a button and then a prop so that the consumer can pass an onClick to the button.
(CDPE-3578) Fix styles, add interactive example & CHANGELOG
I was having trouble with CSS inheritence and honestly its probably not right still, but I was able to make the leading icon sit all the way to the left finally. This change also adds to the Input.md and adds a CHANGELOG entry for these changes as per CONTRIBUTING.md