chore(blog): guard keydown for IME composition and <select>

Code review forward-proofing:
- Early-return on event.isComposing so the / shortcut doesn't disrupt
  IME composition (multi-keystroke input methods).
- Treat <select> as editable so / doesn't steal focus while a dropdown
  is open and the user is typing to seek.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Josh Bairstow 2026-06-02 01:35:53 +10:00
parent 963ea56314
commit 75e7859146

View file

@ -146,12 +146,14 @@
// contenteditable element). `Esc` while the input is focused clears the
// query, blurs, and restores the full archive.
document.addEventListener("keydown", (event) => {
if (event.isComposing) return;
if (event.key === "/" && !event.metaKey && !event.ctrlKey && !event.altKey) {
const target = event.target as HTMLElement | null;
const tag = target?.tagName;
const editable =
tag === "INPUT" ||
tag === "TEXTAREA" ||
tag === "SELECT" ||
target?.isContentEditable === true;
if (!editable) {
event.preventDefault();