updated password input behavior. fixes #762 & fixes #763

This commit is contained in:
Danny Coates 2018-02-21 09:54:53 -08:00
parent fa510af65a
commit 099012fac9
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
2 changed files with 20 additions and 5 deletions

View File

@ -7,11 +7,11 @@ module.exports = function(file, state, emit) {
? 'passwordInput' ? 'passwordInput'
: 'passwordInput passwordInput--hidden'; : 'passwordInput passwordInput--hidden';
const inputClass = loading || pwd ? 'input' : 'input input--noBtn'; const inputClass = loading || pwd ? 'input' : 'input input--noBtn';
let btnClass = 'inputBtn inputBtn--hidden'; let btnClass = 'inputBtn inputBtn--password inputBtn--hidden';
if (loading) { if (loading) {
btnClass = 'inputBtn inputBtn--loading'; btnClass = 'inputBtn inputBtn--password inputBtn--loading';
} else if (pwd) { } else if (pwd) {
btnClass = 'inputBtn'; btnClass = 'inputBtn inputBtn--password';
} }
const action = pwd const action = pwd
@ -30,6 +30,7 @@ module.exports = function(file, state, emit) {
autocomplete="off" autocomplete="off"
type="password" type="password"
oninput=${inputChanged} oninput=${inputChanged}
onfocus=${focused}
placeholder="${ placeholder="${
pwd pwd
? passwordPlaceholder(file.password) ? passwordPlaceholder(file.password)
@ -65,11 +66,22 @@ module.exports = function(file, state, emit) {
} }
} }
function focused(event) {
event.preventDefault();
const el = document.getElementById('password-input');
if (el.placeholder !== state.translate('unlockInputPlaceholder')) {
el.placeholder = '';
}
}
function setPassword(event) { function setPassword(event) {
event.preventDefault(); event.preventDefault();
const password = document.getElementById('password-input').value; const el = document.getElementById('password-input');
const password = el.value;
if (password.length > 0) { if (password.length > 0) {
emit('password', { password, file }); emit('password', { password, file });
} else {
el.focus();
} }
return false; return false;
} }

View File

@ -21,7 +21,10 @@
background-position: center; background-position: center;
background-size: 30px 30px; background-size: 30px 30px;
background-repeat: no-repeat; background-repeat: no-repeat;
flex-basis: 20%; }
.inputBtn--password {
flex: 0 0 200px;
} }
@media (max-device-width: 520px), (max-width: 520px) { @media (max-device-width: 520px), (max-width: 520px) {