mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
[PM-16132][16249] Custom hidden field missing color and character count toggle (#13402)
* Add colored characters to custom hidden field * Add character count toggle to hidden field * Check correct variable for revealed hidden field * Merge branch 'main' into vault/pm-16132/custom-hidden-field-missing-color-and-character-count-toggle * Toggle character count on per field basis --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com> Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com> Co-authored-by: Leslie Tilton <23057410+Banrion@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d5a7e563c1
commit
574891d617
@@ -51,6 +51,20 @@
|
|||||||
class="tw-font-mono"
|
class="tw-font-mono"
|
||||||
vaultAutosizeReadOnlyTextArea
|
vaultAutosizeReadOnlyTextArea
|
||||||
></textarea>
|
></textarea>
|
||||||
|
<button
|
||||||
|
*ngIf="canViewPassword && revealedHiddenFields.includes(i)"
|
||||||
|
bitIconButton="bwi-numbered-list"
|
||||||
|
bitSuffix
|
||||||
|
type="button"
|
||||||
|
data-testid="toggle-hidden-field-value-count"
|
||||||
|
[appA11yTitle]="
|
||||||
|
(showHiddenValueCountFields.includes(i) ? 'hideCharacterCount' : 'showCharacterCount')
|
||||||
|
| i18n
|
||||||
|
"
|
||||||
|
[attr.aria-expanded]="showHiddenValueCountFields.includes(i)"
|
||||||
|
appStopClick
|
||||||
|
(click)="toggleCharacterCount(i)"
|
||||||
|
></button>
|
||||||
<button
|
<button
|
||||||
bitSuffix
|
bitSuffix
|
||||||
type="button"
|
type="button"
|
||||||
@@ -71,6 +85,12 @@
|
|||||||
(click)="logCopyEvent()"
|
(click)="logCopyEvent()"
|
||||||
></button>
|
></button>
|
||||||
</bit-form-field>
|
</bit-form-field>
|
||||||
|
<div
|
||||||
|
*ngIf="showHiddenValueCountFields.includes(i) && revealedHiddenFields.includes(i)"
|
||||||
|
[ngClass]="{ 'tw-mt-3': true, 'tw-mb-2': true }"
|
||||||
|
>
|
||||||
|
<bit-color-password [password]="field.value" [showCount]="true"></bit-color-password>
|
||||||
|
</div>
|
||||||
<bit-form-control *ngIf="field.type === fieldType.Boolean">
|
<bit-form-control *ngIf="field.type === fieldType.Boolean">
|
||||||
<input
|
<input
|
||||||
bitCheckbox
|
bitCheckbox
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
SectionHeaderComponent,
|
SectionHeaderComponent,
|
||||||
TypographyModule,
|
TypographyModule,
|
||||||
CheckboxModule,
|
CheckboxModule,
|
||||||
|
ColorPasswordModule,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
|
|
||||||
import { VaultAutosizeReadOnlyTextArea } from "../../directives/readonly-textarea.directive";
|
import { VaultAutosizeReadOnlyTextArea } from "../../directives/readonly-textarea.directive";
|
||||||
@@ -40,6 +41,7 @@ import { VaultAutosizeReadOnlyTextArea } from "../../directives/readonly-textare
|
|||||||
SectionHeaderComponent,
|
SectionHeaderComponent,
|
||||||
TypographyModule,
|
TypographyModule,
|
||||||
CheckboxModule,
|
CheckboxModule,
|
||||||
|
ColorPasswordModule,
|
||||||
VaultAutosizeReadOnlyTextArea,
|
VaultAutosizeReadOnlyTextArea,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -51,6 +53,11 @@ export class CustomFieldV2Component implements OnInit {
|
|||||||
/** Indexes of hidden fields that are revealed */
|
/** Indexes of hidden fields that are revealed */
|
||||||
revealedHiddenFields: number[] = [];
|
revealedHiddenFields: number[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the hidden field's character count should be shown
|
||||||
|
*/
|
||||||
|
showHiddenValueCountFields: number[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private eventCollectionService: EventCollectionService,
|
private eventCollectionService: EventCollectionService,
|
||||||
@@ -69,6 +76,15 @@ export class CustomFieldV2Component implements OnInit {
|
|||||||
return this.cipher.viewPassword;
|
return this.cipher.viewPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleCharacterCount(index: number) {
|
||||||
|
const fieldIndex = this.showHiddenValueCountFields.indexOf(index);
|
||||||
|
if (fieldIndex > -1) {
|
||||||
|
this.showHiddenValueCountFields.splice(fieldIndex, 1);
|
||||||
|
} else {
|
||||||
|
this.showHiddenValueCountFields.push(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async toggleHiddenField(hiddenFieldVisible: boolean, index: number) {
|
async toggleHiddenField(hiddenFieldVisible: boolean, index: number) {
|
||||||
if (hiddenFieldVisible) {
|
if (hiddenFieldVisible) {
|
||||||
this.revealedHiddenFields.push(index);
|
this.revealedHiddenFields.push(index);
|
||||||
|
|||||||
Reference in New Issue
Block a user