Bug 1831248 - Fix conceal/show button not working properly. r=mtigley

Fixes password input behaviour.
- The password text will be revealed when focused from oustide (i.e not triggered by reveal button )
- The password text will be concealed when blurred.
- The password text will show / hide depending on reveal button state. Edit is possible when password is hidden by reveal button.

**Old behaviour:**
{F4936523}

**Current behaviour:**
{F4936530}

Differential Revision: https://phabricator.services.mozilla.com/D180979
This commit is contained in:
Issam Mani 2023-06-15 20:47:12 +00:00
Родитель 66f4fff3a4
Коммит bb11d23e87
1 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -308,6 +308,13 @@ export default class LoginItem extends HTMLElement {
break;
}
case "blur": {
// TODO(Bug 1838494): Remove this if block
// This is a temporary fix until Bug 1750072 lands
const focusCheckboxNext = event.relatedTarget === this._revealCheckbox;
if (focusCheckboxNext) {
return;
}
if (this.dataset.editing && event.target === this._passwordInput) {
this._revealCheckbox.checked = false;
this._updatePasswordRevealState();
@ -331,9 +338,18 @@ export default class LoginItem extends HTMLElement {
break;
}
case "focus": {
const { target } = event;
// TODO(Bug 1838494): Remove this if block
// This is a temporary fix until Bug 1750072 lands
const focusFromCheckbox = event.relatedTarget === this._revealCheckbox;
const isEditingMode = this.dataset.editing || this.dataset.isNewLogin;
if (focusFromCheckbox && isEditingMode) {
this._passwordInput.type = this._revealCheckbox.checked
? "text"
: "password";
return;
}
if (target === this._passwordDisplayInput) {
if (event.target === this._passwordDisplayInput) {
this._revealCheckbox.checked = !!this.dataset.editing;
this._updatePasswordRevealState();
}
@ -343,6 +359,14 @@ export default class LoginItem extends HTMLElement {
case "click": {
let classList = event.currentTarget.classList;
if (classList.contains("reveal-password-checkbox")) {
// TODO(Bug 1838494): Remove this if block
// This is a temporary fix until Bug 1750072 lands
if (this.dataset.editing || this.dataset.isNewLogin) {
this._passwordDisplayInput.replaceWith(this._passwordInput);
this._passwordInput.type = "text";
this._passwordInput.focus();
return;
}
// We prompt for the primary password when entering edit mode already.
if (this._revealCheckbox.checked && !this.dataset.editing) {
let primaryPasswordAuth = await promptForPrimaryPassword(