The password toggle was inverted on every password field

The variable was called 'reveal' and held `input.type === 'password'` - which is true
when the password is HIDDEN - and was then used to pick the label. So a masked field
offered 'Hide', and clicking it revealed the password and relabelled itself 'Show'. The
click handler inverted the same way, so the two errors cancelled and the visible result
was a control that appeared to work while doing the opposite of what it said.

Renamed to 'visible', which is what the value now means. A correct-looking name is not
what prevents this; the value and the name agreeing is.

Affects the login field and both fields on the change-password screen.

Verified by running the two states rather than by reading the edit: masked says 'Show',
plain says 'Hide', and two clicks return to the start.
This commit is contained in:
umbra audio
2026-10-03 19:56:03 -07:00
parent 0a4c400022
commit 0b898316ef

View File

@@ -65,11 +65,12 @@
if (!button || !input) {
return;
}
var reveal = input.type === 'password';
button.setAttribute('aria-pressed', reveal ? 'true' : 'false');
button.textContent = reveal ? 'Hide' : 'Show';
button.setAttribute('aria-label', (reveal ? 'Hide' : 'Show') + ' ' + (input.getAttribute('data-field-label') || 'password'));
}
// `visible`, not `reveal`: the old name held the *hidden* test and was then
// used to pick the label, so a hidden password offered "Hide". See the note above.
var visible = input.type === 'text';
button.setAttribute('aria-pressed', visible ? 'true' : 'false');
button.textContent = visible ? 'Hide' : 'Show';
button.setAttribute('aria-label', (visible ? 'Hide' : 'Show') + ' ' + (input.getAttribute('data-toggle-label') || 'password'));
function wirePasswordToggle(buttonId, inputId) {
var button = query('#' + buttonId);
@@ -79,8 +80,7 @@
}
showPasswordToggle(button, input);
button.addEventListener('click', function () {
var reveal = input.type === 'password';
input.type = reveal ? 'text' : 'password';
input.type = input.type === 'text' ? 'password' : 'text';
showPasswordToggle(button, input);
});
}