pw_web: Resume autoscroll with clear logs event

Change-Id: Ibb1459ba4a92cf244440e00d5e56061b7356d8d5
Fixed: 309546085
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/179252
Reviewed-by: Asad Memon <asadmemon@google.com>
Commit-Queue: Amy Hu <amyhu@google.com>
diff --git a/pw_web/log-viewer/src/components/log-list/log-list.ts b/pw_web/log-viewer/src/components/log-list/log-list.ts
index c0a984f..58d635c 100644
--- a/pw_web/log-viewer/src/components/log-list/log-list.ts
+++ b/pw_web/log-viewer/src/components/log-list/log-list.ts
@@ -296,19 +296,26 @@
     const isScrollingUp = currentScrollTop < this.lastScrollTop;
     this.lastScrollTop = currentScrollTop;
 
-    // Only run autoscroll logic if the user is scrolling vertically
+    const logsAreCleared = this.logs.length == 0;
+
+    if (logsAreCleared) {
+      this._autoscrollIsEnabled = true;
+      return;
+    }
+
+    // Run autoscroll logic if scrolling vertically
     if (!isScrollingVertically) {
       this._scrollPercentageLeft = scrollLeft / maxScrollLeft || 0;
       return;
     }
 
-    // User is scrolling up, disable autoscroll
+    // Scroll direction up, disable autoscroll
     if (isScrollingUp) {
       this._autoscrollIsEnabled = false;
       return;
     }
 
-    // User is scrolling down, enable autoscroll if they're near the bottom
+    // Scroll direction down, enable autoscroll if near the bottom
     if (Math.abs(scrollY) <= 1) {
       this._autoscrollIsEnabled = true;
       return;
diff --git a/pw_web/testing.rst b/pw_web/testing.rst
index 38d4d77..8b7f29f 100644
--- a/pw_web/testing.rst
+++ b/pw_web/testing.rst
@@ -33,6 +33,16 @@
      - | Logs are cleared and filtered entries after time of button press are addded.
      - |checkbox|
 
+   * - 3
+     - | Table is autoscrolling, scroll up
+     - | Autoscroll is disabled and :guilabel:`jump to bottom` button is visible.
+     - |checkbox|
+
+   * - 4
+     - | Press :guilabel:`clear logs` button  (trash can with lines)
+     - | Autoscroll is enabled and :guilabel:`jump to bottom` button is not visible.
+     - |checkbox|
+
 Add note to the commit message
 ==============================
 Add a ``Testing:`` line to your commit message and mention the steps