aboutsummaryrefslogtreecommitdiff
path: root/static/script.ts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 00:52:51 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 00:52:51 +0100
commiteb9d262c992c0ce0841ce8ce8ab829e486e5c2ba (patch)
tree837983f453ba05724653658e16968c4e0b4e2cc8 /static/script.ts
parentRemove popup.ts, migrating all functionality elsewhere. (diff)
downloadcalp-eb9d262c992c0ce0841ce8ce8ab829e486e5c2ba.tar.gz
calp-eb9d262c992c0ce0841ce8ce8ab829e486e5c2ba.tar.xz
Only focus searchbox on '/' when sensible.
Diffstat (limited to 'static/script.ts')
-rw-r--r--static/script.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/static/script.ts b/static/script.ts
index 34443b16..f243dd67 100644
--- a/static/script.ts
+++ b/static/script.ts
@@ -255,11 +255,12 @@ window.addEventListener('load', function() {
});
document.addEventListener('keydown', function(event) {
- if (event.key == '/') {
- let searchbox = document.querySelector('.simplesearch [name=q]') as HTMLInputElement
- // focuses the input, and selects all the text in it
- searchbox.select();
- event.preventDefault();
- }
+ if (event.key !== '/') return;
+ if ('value' in (event.target as any)) return;
+
+ let searchbox = document.querySelector('.simplesearch [name=q]') as HTMLInputElement
+ // focuses the input, and selects all the text in it
+ searchbox.select();
+ event.preventDefault();
});
})