Expand the check result row, if the check chip was clicked

Release-Notes: skip
Google-Bug-Id: b/347105311
Change-Id: Ie1996c66faf8f4fb98176d44b7f341d37b6e022b
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-results.ts b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
index c5194d5..65fdb93 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-results.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
@@ -473,9 +473,11 @@
     this.toggleExpanded();
   }
 
-  private toggleExpanded() {
+  /** Toggles the expanded state, or if `setExpanded` is provided sets it to the desired state. */
+  toggleExpanded(setExpanded?: boolean) {
     if (!this.isExpandable) return;
-    this.isExpanded = !this.isExpanded;
+    this.isExpanded =
+      setExpanded === undefined ? !this.isExpanded : setExpanded;
     this.reporting.reportInteraction(Interaction.CHECKS_RESULT_ROW_TOGGLE, {
       expanded: this.isExpanded,
       checkName: this.result?.checkName,
@@ -1103,6 +1105,8 @@
       // moment before trying to find a child element in it.
       setTimeout(() => {
         if (el) (el as HTMLElement).focus();
+        // If the target element is a <gr-result-row>, then expand it.
+        (el as GrResultRow)?.toggleExpanded(true);
         // <gr-result-row> has display:contents and cannot be scrolled into view
         // itself. Thus we are preferring to scroll the first child into view.
         el = el?.shadowRoot?.firstElementChild ?? el;