diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-10 00:52:51 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-10 00:52:51 +0100 |
commit | eb9d262c992c0ce0841ce8ce8ab829e486e5c2ba (patch) | |
tree | 837983f453ba05724653658e16968c4e0b4e2cc8 /static/script.ts | |
parent | Remove popup.ts, migrating all functionality elsewhere. (diff) | |
download | calp-eb9d262c992c0ce0841ce8ce8ab829e486e5c2ba.tar.gz calp-eb9d262c992c0ce0841ce8ce8ab829e486e5c2ba.tar.xz |
Only focus searchbox on '/' when sensible.
Diffstat (limited to '')
-rw-r--r-- | static/script.ts | 13 |
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(); }); }) |