From d2fc0879f68d0d0a9175c5c9ef85a02dd8fb13c8 Mon Sep 17 00:00:00 2001
From: Austin Anderson <angerson@google.com>
Date: Tue, 9 May 2023 13:29:05 -0700
Subject: [PATCH] Fix it all, finally

---
 tf_oss_dashboard/script.js         | 16 ++++++++++------
 tf_oss_dashboard/template.html.pug |  2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tf_oss_dashboard/script.js b/tf_oss_dashboard/script.js
index 4182d60..346a756 100644
--- a/tf_oss_dashboard/script.js
+++ b/tf_oss_dashboard/script.js
@@ -97,15 +97,19 @@ $(function () {
     history.replaceState(null, null, ' ')
   })
 
-  // When the page loads, if there is a commit ID in the location hash, show
-  // the matching modal -- that is, if you load dashboard#commit, show the modal
-  // for that commit. Also, show the matching modal if a CL is provided instead.
+  // When the page loads, check the location hash, and...
+  // - If there's a matching category on the page, scroll to it
+  // - If there is a commit ID in the location hash, show that commit
+  // - If there is a CL in the location hash, show that CL's commit
+  // - If there is a PR in the location hash, show that PR's commit
   unescaped = decodeURIComponent(window.location.hash).replace("#", "").replace("+", "")
-  // Nothing to do if no hash in the URL
   if (window.location.hash.length <= 1) {
-     // Empty!
-  // If the hash matches a Category on the page, then scroll to it
+    // Nothing to do if no hash in the URL
+  // If the hash matches a Category on the page, then scroll to it.
   } else if (document.getElementById(unescaped)) {
+    // Google Chrome, at least, does not scroll if the tab is opened in the
+    // background, so we try and scroll a moment after the first time the tab
+    // gets focus, or immediately if it has focus already.
     if (document.hasFocus()) {
       document.getElementById(unescaped).scrollIntoView();
     } else {
diff --git a/tf_oss_dashboard/template.html.pug b/tf_oss_dashboard/template.html.pug
index 8e97c86..d96097d 100644
--- a/tf_oss_dashboard/template.html.pug
+++ b/tf_oss_dashboard/template.html.pug
@@ -21,7 +21,7 @@ html(lang="en")
     nav.navbar.navbar-dark.navbar-expand-lg.py-0.mb-2
       .container-fluid.py-0
         .d-flex.flex-row
-          a.navbar-brand TensorFlow GitHub CI
+          a(href=).navbar-brand TensorFlow GitHub CI
           .navbar-text#tf-now(data-isonow=isonow) Last updated on 
             a(title="Check the dashboard deployment GitHub Actions workflow" href="https://github.com/tensorflow/build/actions/workflows/dashboard.yml") #{now}
             |  
-- 
GitLab