Skip to content

Commit 849d777

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: improve visual look of annotation input with consent flow
When the consent flow popped up, the input lost focus and it renders as a black rectangle (as it has no content). This CL updates it to maintain the same visual state. It also fixes a bug where focus was not properly restored; the early exit condition in the setLabelEditabilityAndRemoveEmptyLabel function meant that we wouldn't call focus, so I removed that. It's a pretty cheap function that is not triggered that much so any theoretical boost by early exiting is not worth it given it caused a bug. Bug: 393063467 Change-Id: Id377a6ebee5b4ce0d4649e09f8fe7cbd5ed8d128 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6403241 Reviewed-by: Alina Varkki <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Jack Franklin <[email protected]>
1 parent e003c58 commit 849d777

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,6 @@ export class EntryLabelOverlay extends HTMLElement {
454454
}
455455

456456
setLabelEditabilityAndRemoveEmptyLabel(editable: boolean): void {
457-
// Exit out if the current editable state matches the new one.
458-
if (editable === this.#isLabelEditable) {
459-
return;
460-
}
461-
462457
// We skip this if we have taken the user to the AI FRE flow, because we want the label still there when they come back.
463458
if (this.#inAIConsentDialogFlow && editable === false) {
464459
return;
@@ -538,6 +533,7 @@ export class EntryLabelOverlay extends HTMLElement {
538533
} else {
539534
this.#isAILabelLoading = false;
540535
this.#inAIConsentDialogFlow = true;
536+
this.#render();
541537
const hasConsented = await this.#showUserAiFirstRunDialog();
542538
this.#inAIConsentDialogFlow = false;
543539
// This makes sure we put the user back in the editable state.
@@ -793,16 +789,22 @@ export class EntryLabelOverlay extends HTMLElement {
793789
}
794790

795791
#render(): void {
792+
const inputFieldClasses = Lit.Directives.classMap({
793+
'input-field': true,
794+
// When the consent modal pops up, we want the input to look like it has focus so it visually doesn't change.
795+
// Once the consent flow is closed, we restore focus and maintain the appearance.
796+
'fake-focus-state': this.#inAIConsentDialogFlow,
797+
});
796798
// clang-format off
797799
Lit.render(
798800
html`
799801
<span class="label-parts-wrapper" role="region" aria-label=${i18nString(UIStrings.entryLabel)}
800-
@focusout=${this.#handleFocusOutEvent}
802+
@focusout=${this.#handleFocusOutEvent}
801803
>
802804
<span
803805
class="label-button-input-wrapper">
804806
<span
805-
class="input-field"
807+
class=${inputFieldClasses}
806808
role="textbox"
807809
@focus=${() => {
808810
this.setLabelEditabilityAndRemoveEmptyLabel(true);

front_end/panels/timeline/overlays/components/entryLabelOverlay.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@
115115
* empty annotation, and then tab to the GenerateAI button, the text field
116116
* styling doesn't change. */
117117
.input-field:focus,
118-
.label-parts-wrapper:focus-within .input-field {
118+
.label-parts-wrapper:focus-within .input-field,
119+
.input-field.fake-focus-state {
119120
background-color: var(--color-background);
120121
color: var(--color-background-inverted);
121122
outline: 2px solid var(--color-background-inverted);

0 commit comments

Comments
 (0)