Merge "Fix unhandled promise rejections and test type errors"
diff --git a/polygerrit-ui/app/embed/diff/gr-diff/gr-diff.ts b/polygerrit-ui/app/embed/diff/gr-diff/gr-diff.ts
index c5fef11..1fb0664 100644
--- a/polygerrit-ui/app/embed/diff/gr-diff/gr-diff.ts
+++ b/polygerrit-ui/app/embed/diff/gr-diff/gr-diff.ts
@@ -367,6 +367,15 @@
   }
 
   protected override willUpdate(changedProperties: PropertyValues<this>): void {
+    if (changedProperties.has('groups')) {
+      if (this.groups?.length > 0) {
+        this.loading = false;
+      }
+    }
+    if (changedProperties.has('diff')) {
+      this.loading = true;
+    }
+
     if (
       changedProperties.has('diff') ||
       changedProperties.has('path') ||
@@ -472,11 +481,6 @@
       // diffChanged relies on diffElement having been rendered.
       this.diffChanged();
     }
-    if (changedProperties.has('groups')) {
-      if (this.groups?.length > 0) {
-        this.loading = false;
-      }
-    }
   }
 
   override render() {
@@ -688,7 +692,6 @@
   }
 
   private diffChanged() {
-    this.loading = true;
     if (this.diff && this.diffElement) {
       this.diffSelection.init(this.diff, this.diffElement);
       this.highlights.init(this.diffElement, this);