Skip to content
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

Merged
merged 7 commits into from May 28, 2018
Merged

Add password visibility toggle feature #2429

merged 7 commits into from May 28, 2018

Conversation

c-ciobanu
Copy link
Contributor

My solution for the issue #2360.
What do you think?
Something to improve?

@xPaw
Copy link
Member

xPaw commented May 8, 2018

There's also a password field on login and connect (edit) windows.

@xPaw xPaw added this to Todo in Accessibility via automation May 8, 2018
@xPaw xPaw added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label May 8, 2018
@c-ciobanu
Copy link
Contributor Author

I was thinking of creating a tpl file with the password block so you can put it where you want.
Need to take a look at handlebars.

@xPaw
Copy link
Member

xPaw commented May 8, 2018

I don't think a separate template is necessary, as every input is going to be different.

@c-ciobanu
Copy link
Contributor Author

Can i add more committs to this pull request or i have to create a new one?

@xPaw
Copy link
Member

xPaw commented May 8, 2018

This PR is just a branch, you can keep pushing to it.

@c-ciobanu
Copy link
Contributor Author

Ok, later will add the 2 other fields.

}

#settings #change-password .see-pw::before {
content: "\f06e";
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

width: 100%;
}

.password-container .see-pw {
Copy link
Member

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.

content: "\f06e"; /* https://fontawesome.com/icons/eye?style=solid */
}

.password-container .see-pw.visible::before {
Copy link
Member

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.

@xPaw
Copy link
Member

xPaw commented May 9, 2018

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 padding-right on the input itself, so that the button doesn't overlay the text.

<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>
Copy link
Member

@xPaw xPaw May 9, 2018

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:
    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.

@c-ciobanu
Copy link
Contributor Author

Fixed all the things following your suggestions.
Coudn't create a new template, can't understand how the templates interact with each other.
If you can explain it to me would be great.

}

.password-container .reveal-password i::before {
content: "\f06e"; /* https://fontawesome.com/icons/eye?style=solid */

This comment was marked as resolved.

position: absolute;
top: 2px;
right: 15px;
cursor: pointer;
Copy link
Member

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?

Copy link
Member

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.

<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">
Copy link
Member

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!

<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>
Copy link
Member

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.

@astorije
Copy link
Member

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:

  • Connect window: screen shot 2018-05-10 at 01 03 56
  • Login page: screen shot 2018-05-10 at 01 04 53

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() {
Copy link
Member

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).

Copy link
Member

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?

@xPaw
Copy link
Member

xPaw commented May 10, 2018

@c-ciobanu for a template, you just create a file in views folder (like reveal-password.tpl) and then include it like {{> reveal-password}} in html where you need it.

@c-ciobanu
Copy link
Contributor Author

@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.
For the span and i i would do something like this:

<span class="tooltipped tooltipped-n tooltipped-no-delay" aria-label="Show password">
<button type="button" class="reveal-password" aria-label="Show password" data-alt-label="Hide password"></button>
</span>

This can go?
@xPaw can i associate a js file with the logic to the template like in react or vue?

@xPaw
Copy link
Member

xPaw commented May 10, 2018

@xPaw can i associate a js file with the logic to the template like in react or vue?

We don't have anything like that setup, sadly.

const $this = $(this);
const input = $this.closest("div").find("input");

input.attr("type") === "password" ? input.attr("type", "text") : input.attr("type", "password");
Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

@astorije
Copy link
Member

For the span and i i would do something like this: [...]
This can go?

Yep, I think it's nicer than <i>, if @xPaw is okay with that (that enables keyboard tabbing so might prefer span, I don't know, up to you guys).

@xPaw
Copy link
Member

xPaw commented May 23, 2018

Use span for consistency with other icons we already have.

@@ -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>
Copy link
Member

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.

Copy link
Contributor Author

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>?

Copy link
Member

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.

@xPaw xPaw requested a review from astorije May 26, 2018 20:59
Copy link
Member

@astorije astorije left a 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 😊

@astorije astorije added this to the 3.0.0 milestone May 28, 2018
@astorije astorije merged commit e30984a into thelounge:master May 28, 2018
Accessibility automation moved this from Todo to Done May 28, 2018
@c-ciobanu
Copy link
Contributor Author

c-ciobanu commented May 29, 2018

Thank you, I'll take a look into it and will submit a pr soon.
Maybe I'll wait for the PRs with css changes to be merged before doing it.
@astorije, @xPaw you thought about using a preprocessor like sass and organize better the css part?

@c-ciobanu c-ciobanu deleted the c-ciobanu/feature-2360 branch May 29, 2018 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
Accessibility
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants