Skip to content

Commit 2f393a7

Browse files
wolfibDevtools-frontend LUCI CQ
authored andcommitted
Add fadeout to highlighting of direct citations
This is more consistent with how it's done elsewhere in DevTools, and it also simplifies the code logic. Screencast: https://i.imgur.com/1muTlA1.mp4 Bug: 393061324 Change-Id: I88bfb546cd2b356327f4892f6ac85a83ff12299e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6291329 Reviewed-by: Alex Rudenko <[email protected]> Auto-Submit: Wolfgang Beyer <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 209498c commit 2f393a7

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

front_end/panels/explain/components/ConsoleInsight.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ type StateData = {
212212
isPageReloadRecommended: boolean,
213213
completed: boolean,
214214
directCitationUrls: string[],
215-
highlightIndex?: number,
216215
timedOut?: boolean,
217216
}&Host.AidaClient.AidaResponse|{
218217
type: State.ERROR,
@@ -311,13 +310,13 @@ export class ConsoleInsight extends HTMLElement {
311310
if (this.#state.type !== State.INSIGHT || !this.#referenceDetailsRef.value) {
312311
return;
313312
}
314-
this.#state.highlightIndex = index;
315313
const areDetailsAlreadyExpanded = this.#referenceDetailsRef.value.open;
316314
this.#areReferenceDetailsOpen = true;
317315
this.#render();
318316

319-
const highlightedElement = this.#shadow.querySelector('li .highlighted');
317+
const highlightedElement = this.#shadow.querySelector(`.sources-list x-link[data-index="${index}"]`);
320318
if (highlightedElement) {
319+
UI.UIUtils.runCSSAnimationOnce(highlightedElement, 'highlighted');
321320
if (areDetailsAlreadyExpanded) {
322321
highlightedElement.scrollIntoView({behavior: 'auto'});
323322
} else { // Wait for the details element to open before scrolling.
@@ -674,27 +673,21 @@ export class ConsoleInsight extends HTMLElement {
674673
return Lit.nothing;
675674
}
676675

677-
const highlightIndex = this.#state.highlightIndex || -1;
678676
// clang-format off
679677
return html`
680678
<ol class="sources-list">
681-
${this.#state.directCitationUrls.map((url, index) => {
682-
const linkClasses = Lit.Directives.classMap({
683-
link: true,
684-
highlighted: highlightIndex - 1 === index,
685-
});
686-
return html`
687-
<li>
688-
<x-link
689-
href=${url}
690-
class=${linkClasses}
691-
jslog=${VisualLogging.link('references.console-insights').track({click: true})}
692-
>
693-
${url}
694-
</x-link>
695-
</li>
696-
`;
697-
})}
679+
${this.#state.directCitationUrls.map((url, index) => html`
680+
<li>
681+
<x-link
682+
href=${url}
683+
class="link"
684+
data-index=${index + 1}
685+
jslog=${VisualLogging.link('references.console-insights').track({click: true})}
686+
>
687+
${url}
688+
</x-link>
689+
</li>
690+
`)}
698691
</ol>
699692
`;
700693
// clang-format on
@@ -749,11 +742,6 @@ export class ConsoleInsight extends HTMLElement {
749742
#onToggleReferenceDetails(): void {
750743
if (this.#referenceDetailsRef.value) {
751744
this.#areReferenceDetailsOpen = this.#referenceDetailsRef.value.open;
752-
if (!this.#areReferenceDetailsOpen && this.#state.type === State.INSIGHT &&
753-
this.#state.highlightIndex !== undefined) {
754-
this.#state.highlightIndex = undefined;
755-
this.#render();
756-
}
757745
}
758746
}
759747

front_end/panels/explain/components/consoleInsight.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,17 @@ h2:focus-visible {
365365
}
366366

367367
.sources-list x-link.highlighted { /* stylelint-disable-line selector-type-no-unknown */
368-
background-color: var(--sys-color-yellow-container);
368+
animation: highlight-fadeout 2s;
369+
}
370+
371+
@keyframes highlight-fadeout {
372+
from {
373+
background-color: var(--sys-color-yellow-container);
374+
}
375+
376+
to {
377+
background-color: transparent;
378+
}
369379
}
370380

371381
.references-list {

0 commit comments

Comments
 (0)