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
Add password visibility toggle feature #2429
Conversation
There's also a password field on login and connect (edit) windows. |
I was thinking of creating a tpl file with the password block so you can put it where you want. |
I don't think a separate template is necessary, as every input is going to be different. |
Can i add more committs to this pull request or i have to create a new one? |
This PR is just a branch, you can keep pushing to it. |
Ok, later will add the 2 other fields. |
client/css/style.css
Outdated
} | ||
|
||
#settings #change-password .see-pw::before { | ||
content: "\f06e"; |
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.
If you could add /** **/
comments here with links to the font-awesome website for consistency with other CSS, that'd be great
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.
Will do
client/css/style.css
Outdated
width: 100%; | ||
} | ||
|
||
.password-container .see-pw { |
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.
Add cursor: pointer
and :hover
styles to change color to something more visible.
client/css/style.css
Outdated
content: "\f06e"; /* https://fontawesome.com/icons/eye?style=solid */ | ||
} | ||
|
||
.password-container .see-pw.visible::before { |
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.
Maybe also change color for visible icon to red or something.
This is conflicting with Edge's own reveal button, which seems to be an easy fix: vuetifyjs/vuetify#537 I think you also need increase |
client/views/windows/settings.tpl
Outdated
<label for="verify_password_input" class="sr-only">Repeat new password</label> | ||
<input type="password" id="verify_password_input" name="verify_password" class="input" placeholder="Repeat new password"> | ||
<i class="see-pw" title="Show Password"></i> |
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.
- Use
aria-label
(you can also add tooltipped class to show a proper tooltip). - Put `Hide password in an alt-attribute something like that:
thelounge/client/js/socket-events/more.js
Line 118 in 49c5e6a
function swapText(btn) { - Since
see-pw
element is a little verbose, you could make a separate template file for it. - Change the classname to something more verbose like
reveal-password
.
Fixed all the things following your suggestions. |
client/css/style.css
Outdated
} | ||
|
||
.password-container .reveal-password i::before { | ||
content: "\f06e"; /* https://fontawesome.com/icons/eye?style=solid */ |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
client/css/style.css
Outdated
position: absolute; | ||
top: 2px; | ||
right: 15px; | ||
cursor: pointer; |
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.
I would love if we could make the .reveal-password
element a button
instead of a span
. It comes with benefits such as no need to set the cursor property, but also improves accessibility with keyboard navigation and such. Thoughts?
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.
I'm not sure it should be keyboard accessible (tabbing into it would be counter intuitive?).
Edge doesn't allow tabbing into their reveal button.
client/views/windows/connect.tpl
Outdated
<input class="input" id="connect:password" type="password" name="password" value="{{defaults.password}}"> | ||
<span class="reveal-password tooltipped tooltipped-n tooltipped-no-delay" aria-label="Show Password" data-alt-label="Hide Password"> |
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.
This is rather nitpicky, but in order to be consistent with similar elements like this, could you go for Show password
and Hide password
(i.e. drop the uppercase on Password
)? Thanks!
client/views/windows/sign_in.tpl
Outdated
<input class="input" type="password" name="password"> | ||
</label> | ||
<span class="reveal-password tooltipped tooltipped-n tooltipped-no-delay" aria-label="Show Password" data-alt-label="Hide Password"> | ||
<i></i> |
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.
I don't think we need (should?) have an i
elements for those. If you look at other icon buttons, you'll see we don't wrap those in i
elements. That will probably mean you'll need a container for the tooltip. That's rather unfortunate, but that's consistent with the rest so that when we improve/change things, we can do it all over the place more easily.
That is great stuff @c-ciobanu, thanks a lot for helping with that!! ❤️ I have noticed (on the default theme) that the icons are not correctly vertically centered: It's more visible on the second one. |
@@ -97,6 +98,24 @@ function toggleNotificationMarkers(newState) { | |||
viewport.toggleClass("notified", newState); | |||
} | |||
|
|||
function togglePasswordField(elem) { | |||
$(elem).on("click", function() { |
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.
This needs to pass in a more specific selector or direct jquery element, otherwise you will be binding multiple events to the same buttons if you open connect window 5 times (it'll bind 5 times on the button in settings).
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.
@xPaw, is this still relevant?
@c-ciobanu for a template, you just create a file in views folder (like |
@astorije the icons are not aligned because the css resets are not working properly, on chrome they look fine but on firex not. A separate file just for resets should be created for clarity, i sow some rules repeated on the css files.
This can go? |
We don't have anything like that setup, sadly. |
client/js/utils.js
Outdated
const $this = $(this); | ||
const input = $this.closest("div").find("input"); | ||
|
||
input.attr("type") === "password" ? input.attr("type", "text") : input.attr("type", "password"); |
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.
input.attr("type", input.attr("type") === "password" ? "text" : "password");
is shorter and reads better.
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.
@c-ciobanu, mind doing this?
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.
Sure, will commit this along with the changes on the <i>
when @xPaw will express his opinion on what to use.
Yep, I think it's nicer than |
Use |
client/views/reveal-password.tpl
Outdated
@@ -0,0 +1,3 @@ | |||
<span class="reveal-password tooltipped tooltipped-n tooltipped-no-delay" aria-label="Show password" data-alt-label="Hide password"> | |||
<button type="button" aria-label="Show password" data-alt-label="Hide password"></button> |
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.
You changed it to button
instead of span
as discussed.
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.
i thought you wanted them to be consistent with the other icons, a <button>
inside a <span>
. To be sure, you want a <span>
inside a <span>
?
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.
Yes. In this instance we don't want to use button
.
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.
The icons are still not peeerfectly aligned (I think it's more visible on login page, though I have not measured), but this is already pretty good!
It would be lovely if you could follow-up in a further PR to accurately vertically center the icon. Either way, thanks a lot, this is solid work!! 👏
And congrats on your first PR here! Since you are now a contributor, feel free to request a sticker pack at goo.gl/forms/f5usqAEp5DWoeXC92 😊
My solution for the issue #2360.
What do you think?
Something to improve?