hterm: keep focus on FindBar after scroll

Calling syncSelectionCaret brings focus to the screen element.  When
FindBar has focus and scrolling is happening due to next/prev, we should
not call syncSelectionCaret so that we can keep the focus on FindBar.

Change-Id: Icebcb40a722f13d38bfe8bceaf608db8557fc71a
Reviewed-on: https://chromium-review.googlesource.com/c/apps/libapps/+/2330875
Reviewed-by: Shivang Garg <shivanggarg@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index a6957cd..9b56980 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -3190,10 +3190,13 @@
                                 ', ' + this.screen_.cursorPosition.row +
                                 ')');
 
-  // Update the caret for a11y purposes.
-  const selection = this.document_.getSelection();
-  if (selection && (selection.isCollapsed || forceSyncSelection)) {
-    this.screen_.syncSelectionCaret(selection);
+  // Update the caret for a11y purposes unless FindBar has focus which it should
+  // keep.
+  if (!this.findBar.hasFocus) {
+    const selection = this.document_.getSelection();
+    if (selection && (selection.isCollapsed || forceSyncSelection)) {
+      this.screen_.syncSelectionCaret(selection);
+    }
   }
   return true;
 };