-
Notifications
You must be signed in to change notification settings - Fork 42
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
Created PasswordInput component with visibility button (eye icon) #750
Created PasswordInput component with visibility button (eye icon) #750
Conversation
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.
Hi Balsa!
To begin with, thanks a lot for this new contribution! Clearly, it resolves #242.
There are, however, a few changes I would like to suggest:
-
Use the "eye icon pattern"
I.e., to put an eye icon close to the password input for revealing or hiding its content. Similar to the Cockpit's login page implements it.
An example of how to do it with PatternFly is here and you can use the "Visibility" and "Visibility off" icons provided by material symbols importing them in the Icon component.
-
Opting for a toggle action rather than a "momentary" one
I.e., make the password input visible (or not) upon clicking.
Hope you don't mind, but I think it's a well-known, slightly better approach.
changed to toggle visibility on click and not on hold
Hey David, Don't mind at all, in fact thank you for taking the time to point me in the right direction. I've made some commits in accordance with your comments, so check it out and let me know if there is anything more I should do regarding this. I noticed something that bothered me a bit but wasn't sure how to fix it—the horizontal alignment of the eye icon within the button doesn't seem quite centered; it's slightly shifted towards the top. It might not be a big deal, but I thought I'd point it out. Testing pics: |
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.
Don't mind at all, in fact thank you for taking the time to point me in the right direction.
I've made some commits in accordance with your comments, so check it out and let me know if there is anything more I should do regarding this.
Wow! That was really fast! Thank you!
I've added a few comments more. Once you address them, we can continue working to go a a bit further 😇 is you're willing to do so 😉
I noticed something that bothered me a bit but wasn't sure how to fix it—the horizontal alignment of the eye icon within the button doesn't seem quite centered; it's slightly shifted towards the top. It might not be a big deal, but I thought I'd point it out.
The quick fix that comes to my mind now is to add a "display: flex" to the span.pf-c-button__icon
wrapping the icon. Just add below lines to the end of src/assets/styles/patternfly-overrides.scss file
button#password_visibility span.pf-c-button__icon {
display: flex;
}
We can go for a better solution later, once the migration to PatternFly 5 is done.
this variable is then used in icon prop of the Button
In the WiFi form where password is entered
This comment was marked as resolved.
This comment was marked as resolved.
No strong opinion from my side. Your choice is ok. Let's save lines of code until they are really needed 😉
Great! So, to be clear: from my point of view, the PR is ready to be merged as it is now. However, with very little effort, we can improve it a lot for extending that behavior to all password inputs. The idea is
Do you accept the challenge? |
Of course, you can ping us at any moment you have doubts or need help. We can even jump into the PR for writing the unit test if you get stuck there. |
Accepted, I'll get on it. Also thanks for the pointers, they certainly help a lot. |
component also contains eye icon used to show/hide password
…asanovic/agama into wifi-password-show-button
This comment was marked as resolved.
This comment was marked as resolved.
Just my 2 cents about this topic. The "password confirmation" ensures you have typed the same in both inputs, and the "visibility icon" allows you to check you have typed what you really wanted. For me they are complementary. And IMHO, the "visibility icon" is even more important than the confirmation input. Reading the password is the safest way to check that I have really entered it correctly . In fact, having a confirmation is usually useless for me. Many times I write the password correctly but the confirmation wrongly. So having only the password input and the option to read it would be even faster and more secure for me. And using autogenerated password would make the confirmation even more useless (you probably copy-paste in both inputs :-P). It is only a reflection. I am not suggesting to do this ;-). |
reverted to using FormGroup
component is now used for all password inputs and not just WiFi
…asanovic/agama into wifi-password-show-button
Haha, why not, glad to clean up 😄 I think I covered all suggested changes. Also, I addressed #760 while working on PasswordConfirmation component, so split prop is gone along with its wrapper. Additionally, with the help of @joseivanlopez comment
I succeeded in reaching Luks Activation Question component and testing the password input. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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.
From my point of view, it looks pretty good now. Thanks a lot for such a GREAT job
I've added a few minor suggestions, but the PR is ok as it is.
Also thanks to @nobkd for reviewing and contributing to make the PR even better.
made id prop required, logging to console if it's not provided
Don't mention it, anytime. Added documentation comments and extracted the id prop. |
Problem
When typing the Wi-Fi password user does not have a way to see what was actually typed in, since the password is hidden by default.
fixes #242
Solution
A new component, PasswordInput, has been created. It includes both a text input field and a visibility button with an eye icon.
When the visibility button is clicked, it toggles the text input's form type from 'password' to 'text,' making the characters visible to the user.
This component is now utilized wherever the input type 'password' was previously employed.
As of the time of writing, this applies to the following components:
Also this PR now fixes #760 after the issue was raised while making reviews here.
Testing
Added unit test for the new component in file PasswordInput.test.jsx.
Also tested manually.
Screenshots
Password input in Users menu
Wi-Fi password input
iSCSI storage password input
Luks activation question password input