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

Password reveal button not always placed correctly #22

Open
simu opened this issue Feb 27, 2019 · 14 comments
Open

Password reveal button not always placed correctly #22

simu opened this issue Feb 27, 2019 · 14 comments
Labels
bug ui UI improvement

Comments

@simu
Copy link
Owner

simu commented Feb 27, 2019

After removing the dependency on jquery for the whole extension, my custom password reveal button is not always positioned correctly in relation to the password field.

Goals

  • Improved placement algorithm for the reveal button
@simu simu added ui UI improvement bug labels Feb 27, 2019
@lord2800
Copy link

I've encountered this a lot. It would be nice if this could be disabled via a setting as well--I generally don't use that button in favor of the url bar toggle.

@simu
Copy link
Owner Author

simu commented Aug 13, 2019

I haven't had much time to work on the extension recently, I'll look into adding an option to disable the reveal button, as fixing the positioning is rather harder than adding another option.

@lord2800
Copy link

I can maybe poke at it if you give me a bit of guidance on where to look.

@simu
Copy link
Owner Author

simu commented Aug 13, 2019

The button is implemented by hand using some javascript in

function createMaskButton(field) {
if (debug) console.log("creating mask button for field " + field.id);
/* create unmask button */
var maskbutton = document.createElement('div');
maskbutton.classList.add('passhashbutton');
/* position at the bottom right corner of password field */
var fs = getStyles(field, [ 'display', 'width', 'height',
'padding-top', 'padding-bottom', 'padding-left', 'padding-right',
'margin-top', 'margin-bottom', 'margin-left',
'border-bottom-right-radius', 'border-top-width',
'border-bottom-width', 'border-left-width', 'border-right-width']);
if (fs.display == 'none') {
// shortcircuit when field is display:none
return maskbutton;
}
field.parentNode.insertBefore(maskbutton, field);
// We get the field dimensions from the field's computed styles
var margintop = fs.height + fs['border-top-width'] +
fs['border-bottom-width'] + fs['padding-top'] + fs['padding-bottom'] +
fs['margin-top'];
maskbutton.style['margin-top'] = `${margintop}px`;
if (debug) console.log("maskbutton.margin-top: " + maskbutton.style['margin-top']);
var marginleft = fs.width - fs['border-bottom-right-radius'] - 30 +
fs['border-left-width'] + fs['padding-left'] + fs['margin-left'] +
fs['padding-right'];
maskbutton.style['margin-left'] = `${marginleft}px`;
if (debug) console.log("maskbutton.margin-left: " + maskbutton.style['margin-left']);
return maskbutton;
}

A new option can be implemented in options.html/options.js and used in content-script.js to not create the button by simply not calling createMaskButton() in bind().

@lord2800
Copy link

lord2800 commented Oct 2, 2019

I created #23 to have an option to disable the button and I'm working on fixing the styles to just anchor it to the bottom right corner. I just need to finish testing my changes, then I'll have a PR for that too.

@lord2800
Copy link

lord2800 commented Oct 3, 2019

I created #25 to fix the button placement as well as a few other minor things. If #23 lands first, I'll have to rebase #25 to handle the new place to call requestAnimationFrame, otherwise I'll have to rebase #23 to do it. Either way, let me know and I'll get the other fixed up.

@simu
Copy link
Owner Author

simu commented Oct 10, 2019

@lord2800 thanks for the contributions, I'll try to have a look ASAP

@simu
Copy link
Owner Author

simu commented Oct 31, 2019

@lord2800 Sorry for the long delay, work was super busy. I've merged #23. #25 LGTM as well under the assumption that the new call site to initAllElements is properly updated.

@lord2800
Copy link

On it!

@simu
Copy link
Owner Author

simu commented Oct 31, 2019

While #25 and #28 improve the positioning on some pages, others still struggle, e.g. gitlab.com:
image
image

I'm going to leave this issue open for now, in case someone (or myself when I'm bored enough) can try to come up with a better way. I think what's missing is that the content-script.js isn't really able to react correctly when already existing elements are moved around. Maybe there's a way to subscribe on position updates for individual elements and react to those, but that's an idea for another day.

@lord2800
Copy link

I'll see what I can do! Knowing that gitlab has an issue still makes it easier for me to test out different solutions.

@simu
Copy link
Owner Author

simu commented Nov 1, 2019

Other pages which I've found where the button is still placed weird are:

  • Google
    image

@lord2800
Copy link

lord2800 commented Nov 1, 2019

Interesting. I explicitly tested there too. :(

@simu
Copy link
Owner Author

simu commented Nov 1, 2019

maybe my changes to make it work on my default test (https://store.steampowered.com/login/?redir=&redir_ssl=1) (cf. #28) broke it on Google again, but that just shows that it's really tricky to get this right in all cases :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ui UI improvement
Projects
None yet
Development

No branches or pull requests

2 participants