Skip to content

Commit b9d99f9

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Migrate off CheckboxLabel in the WebAuthn panel
Currently input in and label are being taken out of the `dt-checkbox` shadow root and attached directly to the panel. Not only this is weird and probably buggy, it also prevents me from refactoring and eventually eliminating the CheckboxLabel Bug: 407751147 Change-Id: Ia64e7b6c24bd73cc09e3238b1962c9555a3a3395 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6440930 Reviewed-by: Kim-Anh Tran <[email protected]> Commit-Queue: Danil Somsikov <[email protected]>
1 parent 11e8f26 commit b9d99f9

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

front_end/panels/webauthn/WebauthnPane.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,8 @@ export class WebauthnPaneImpl extends UI.Widget.VBox implements
259259
#newAuthenticatorForm: HTMLElement|undefined;
260260
#protocolSelect: HTMLSelectElement|undefined;
261261
transportSelect: HTMLSelectElement|undefined;
262-
#residentKeyCheckboxLabel: UI.UIUtils.CheckboxLabel|undefined;
263262
residentKeyCheckbox: HTMLInputElement|undefined;
264-
#userVerificationCheckboxLabel: UI.UIUtils.CheckboxLabel|undefined;
265263
#userVerificationCheckbox: HTMLInputElement|undefined;
266-
#largeBlobCheckboxLabel: UI.UIUtils.CheckboxLabel|undefined;
267264
largeBlobCheckbox: HTMLInputElement|undefined;
268265
addAuthenticatorButton: Buttons.Button.Button|undefined;
269266
#isEnabling?: Promise<void>;
@@ -608,33 +605,33 @@ export class WebauthnPaneImpl extends UI.Widget.VBox implements
608605
UI.ARIAUtils.bindLabelToControl(transportSelectTitle, (this.transportSelect as Element));
609606
// transportSelect will be populated in updateNewAuthenticatorSectionOptions.
610607

611-
this.#residentKeyCheckboxLabel =
612-
UI.UIUtils.CheckboxLabel.create(i18nString(UIStrings.supportsResidentKeys), false, undefined, 'resident-key');
613-
this.#residentKeyCheckboxLabel.textElement.classList.add('authenticator-option-label');
614-
residentKeyGroup.appendChild(this.#residentKeyCheckboxLabel.textElement);
615-
this.residentKeyCheckbox = this.#residentKeyCheckboxLabel.checkboxElement;
608+
const residentKeyCheckboxLabel =
609+
UI.UIUtils.createLabel(i18nString(UIStrings.supportsResidentKeys), 'authenticator-option-label');
610+
residentKeyCheckboxLabel.setAttribute('jslog', `${VisualLogging.toggle('resident-key').track({change: true})}`);
611+
residentKeyGroup.appendChild(residentKeyCheckboxLabel);
612+
this.residentKeyCheckbox = residentKeyGroup.createChild('input', 'authenticator-option-checkbox');
613+
this.residentKeyCheckbox.type = 'checkbox';
616614
this.residentKeyCheckbox.checked = false;
617-
this.residentKeyCheckbox.classList.add('authenticator-option-checkbox');
618-
residentKeyGroup.appendChild(this.#residentKeyCheckboxLabel);
619-
620-
this.#userVerificationCheckboxLabel = UI.UIUtils.CheckboxLabel.create(
621-
i18nString(UIStrings.supportsUserVerification), false, undefined, 'user-verification');
622-
this.#userVerificationCheckboxLabel.textElement.classList.add('authenticator-option-label');
623-
userVerificationGroup.appendChild(this.#userVerificationCheckboxLabel.textElement);
624-
this.#userVerificationCheckbox = this.#userVerificationCheckboxLabel.checkboxElement;
615+
UI.ARIAUtils.bindLabelToControl(residentKeyCheckboxLabel, this.residentKeyCheckbox);
616+
617+
const userVerificationCheckboxLabel =
618+
UI.UIUtils.createLabel(i18nString(UIStrings.supportsUserVerification), 'authenticator-option-label');
619+
userVerificationCheckboxLabel.setAttribute(
620+
'jslog', `${VisualLogging.toggle('user-verification').track({change: true})}`);
621+
userVerificationGroup.appendChild(userVerificationCheckboxLabel);
622+
this.#userVerificationCheckbox = userVerificationGroup.createChild('input', 'authenticator-option-checkbox');
623+
this.#userVerificationCheckbox.type = 'checkbox';
625624
this.#userVerificationCheckbox.checked = false;
626-
this.#userVerificationCheckbox.classList.add('authenticator-option-checkbox');
627-
userVerificationGroup.appendChild(this.#userVerificationCheckboxLabel);
628-
629-
this.#largeBlobCheckboxLabel =
630-
UI.UIUtils.CheckboxLabel.create(i18nString(UIStrings.supportsLargeBlob), false, undefined, 'large-blob');
631-
this.#largeBlobCheckboxLabel.textElement.classList.add('authenticator-option-label');
632-
largeBlobGroup.appendChild(this.#largeBlobCheckboxLabel.textElement);
633-
this.largeBlobCheckbox = this.#largeBlobCheckboxLabel.checkboxElement;
625+
UI.ARIAUtils.bindLabelToControl(userVerificationCheckboxLabel, this.#userVerificationCheckbox);
626+
627+
const largeBlobCheckboxLabel =
628+
UI.UIUtils.createLabel(i18nString(UIStrings.supportsLargeBlob), 'authenticator-option-label');
629+
largeBlobCheckboxLabel.setAttribute('jslog', `${VisualLogging.toggle('large-blob').track({change: true})}`);
630+
largeBlobGroup.appendChild(largeBlobCheckboxLabel);
631+
this.largeBlobCheckbox = largeBlobGroup.createChild('input', 'authenticator-option-checkbox');
632+
this.largeBlobCheckbox.type = 'checkbox';
634633
this.largeBlobCheckbox.checked = false;
635-
this.largeBlobCheckbox.classList.add('authenticator-option-checkbox');
636-
this.largeBlobCheckbox.name = 'large-blob-checkbox';
637-
largeBlobGroup.appendChild(this.#largeBlobCheckboxLabel);
634+
UI.ARIAUtils.bindLabelToControl(largeBlobCheckboxLabel, this.largeBlobCheckbox);
638635

639636
this.addAuthenticatorButton = UI.UIUtils.createTextButton(
640637
i18nString(UIStrings.add), this.#handleAddAuthenticatorButton.bind(this),

front_end/panels/webauthn/webauthnPane.css

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@
4747
}
4848

4949
.authenticator-option {
50-
> select, > devtools-button {
50+
> select {
5151
margin: 0 var(--sys-size-9) var(--sys-size-3) var(--sys-size-9);
5252
}
5353

54-
> dt-checkbox {
55-
margin: 0 var(--sys-size-9) 0 var(--sys-size-8);
54+
> devtools-button {
55+
margin: var(--sys-size-3) var(--sys-size-9);
56+
}
57+
58+
> input[type="checkbox"] {
59+
margin: var(--sys-size-5) var(--sys-size-9);
5660
}
5761
}
5862

@@ -117,11 +121,6 @@
117121
line-height: 18px;
118122
}
119123

120-
.authenticator-option-checkbox {
121-
position: relative;
122-
top: 2px;
123-
}
124-
125124
.authenticator-field {
126125
margin: var(--sys-size-3) 0;
127126
}
@@ -137,7 +136,7 @@
137136
font: var(--sys-typescale-body5-medium);
138137
padding-right: var(--sys-size-6);
139138
text-align: left;
140-
min-width: 150px;
139+
min-width: 152px;
141140
line-height: 18px;
142141
}
143142

0 commit comments

Comments
 (0)