Commit 2f26e92
fix(search): guard against key-less keydown events in search bar (#1691)
The swizzled SearchBar uses `useDocSearchKeyboardEvents` from
typesense-docsearch-react, which registers a global keydown listener that calls
`event.key.toLowerCase()` with no guard. Synthetic keydown events dispatched by
password managers, autofill, or browser extensions (seen on Safari) can arrive
without a `key`, so `event.key` is undefined and the handler throws
`undefined is not an object (evaluating 'e.key.toLowerCase')`.
Install a capture-phase keydown listener that runs before the upstream handler
and swallows malformed, key-less events via `stopImmediatePropagation()`. A real
user keystroke always carries a `key`, so nothing legitimate is affected.
Generated-By: PostHog Code
Task-Id: e789835e-7941-4ae9-b98e-056e87ff47b1
Co-authored-by: posthog-eu[bot] <226701856+posthog-eu[bot]@users.noreply.github.com>
Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>
Co-authored-by: Chris Hakkaart <chris.hakkaart@seqera.io>1 parent 9de04a6 commit 2f26e92
1 file changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
315 | 337 | | |
316 | 338 | | |
317 | 339 | | |
| |||
0 commit comments