Set query-sk-value's filter input to empty when changing params

Bug: b/324848144
Change-Id: Iebb7d235e28b61e4525b26d02f2361ae82673e30
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/839903
Commit-Queue: Vidit Chitkara <viditchitkara@google.com>
Reviewed-by: Ashwin Verleker <ashwinpv@google.com>
diff --git a/infra-sk/modules/query-sk/query-sk.ts b/infra-sk/modules/query-sk/query-sk.ts
index ab4bd68..e1446f2 100644
--- a/infra-sk/modules/query-sk/query-sk.ts
+++ b/infra-sk/modules/query-sk/query-sk.ts
@@ -224,6 +224,7 @@
     const key = this._keys[this._keySelect!.selection as number];
     this._values!.options = this._paramset[key] || [];
     this._values!.selected = this._query[key] || [];
+    this._values!.clearFilter();
     this._render();
   }
 
diff --git a/infra-sk/modules/query-sk/query-sk_test.ts b/infra-sk/modules/query-sk/query-sk_test.ts
index 05f052d..463ea50 100644
--- a/infra-sk/modules/query-sk/query-sk_test.ts
+++ b/infra-sk/modules/query-sk/query-sk_test.ts
@@ -267,6 +267,25 @@
     assert.deepEqual('', querySk.current_query);
     assert.deepEqual({}, await querySkPO.getCurrentQuery());
   });
+
+  it('clears query-value-sk search input when param selection changes', async () => {
+    const query: ParamSet = {
+      arch: ['arm', 'x86'],
+      config: ['!8888'],
+      compiler: ['~CC'],
+    };
+
+    querySk.current_query = fromParamSet(query);
+
+    await querySkPO.queryValuesSkPO.setFilterInputValue('test');
+    const initialInputVal =
+      await querySkPO.queryValuesSkPO.getFilterInputValue();
+    assert.equal(initialInputVal, 'test');
+
+    await querySkPO.clickKey('compiler');
+    const newInputVal = await querySkPO.queryValuesSkPO.getFilterInputValue();
+    assert.equal(newInputVal, '');
+  });
 });
 
 describe('removePrefix', () => {
diff --git a/infra-sk/modules/query-values-sk/query-values-sk.ts b/infra-sk/modules/query-values-sk/query-values-sk.ts
index 3317698..368e327 100644
--- a/infra-sk/modules/query-values-sk/query-values-sk.ts
+++ b/infra-sk/modules/query-values-sk/query-values-sk.ts
@@ -89,6 +89,10 @@
     this._render();
   }
 
+  public clearFilter(): void {
+    this._clearFilter();
+  }
+
   private _options: string[] = [];
 
   private _filteredOptions: string[] = [];