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:
parent
963ea56314
commit
75e7859146
1 changed files with 2 additions and 0 deletions
|
|
@ -146,12 +146,14 @@
|
||||||
// contenteditable element). `Esc` while the input is focused clears the
|
// contenteditable element). `Esc` while the input is focused clears the
|
||||||
// query, blurs, and restores the full archive.
|
// query, blurs, and restores the full archive.
|
||||||
document.addEventListener("keydown", (event) => {
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (event.isComposing) return;
|
||||||
if (event.key === "/" && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
if (event.key === "/" && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
||||||
const target = event.target as HTMLElement | null;
|
const target = event.target as HTMLElement | null;
|
||||||
const tag = target?.tagName;
|
const tag = target?.tagName;
|
||||||
const editable =
|
const editable =
|
||||||
tag === "INPUT" ||
|
tag === "INPUT" ||
|
||||||
tag === "TEXTAREA" ||
|
tag === "TEXTAREA" ||
|
||||||
|
tag === "SELECT" ||
|
||||||
target?.isContentEditable === true;
|
target?.isContentEditable === true;
|
||||||
if (!editable) {
|
if (!editable) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue