Skip to content
This repository was archived by the owner on Aug 14, 2021. It is now read-only.

Commit d9b4ba6

Browse files
committed
fix: Clicking on search results didn't always work
1 parent c34a61e commit d9b4ba6

File tree

1 file changed

+10
-2
lines changed
  • src/default/assets/js/src/typedoc/components

1 file changed

+10
-2
lines changed

src/default/assets/js/src/typedoc/components/Search.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ export function initSearch() {
5757
);
5858
}
5959

60+
let resultClicked = false;
61+
results.addEventListener("mousedown", () => (resultClicked = true));
62+
results.addEventListener("mouseup", () => {
63+
resultClicked = false;
64+
field.blur();
65+
});
66+
6067
field.addEventListener("focus", () => searchEl.classList.add("has-focus"));
6168
field.addEventListener("blur", () => {
62-
// Delay a bit so that mouse clicks don't get swallowed
63-
setTimeout(() => searchEl.classList.remove("has-focus"), 100);
69+
if (!resultClicked) {
70+
searchEl.classList.remove("has-focus");
71+
}
6472
});
6573

6674
const state: SearchState = {

0 commit comments

Comments
 (0)