Skip to content

fix(search): guard against key-less keydown events in search bar - #1691

Merged
christopher-hakkaart merged 6 commits into
masterfrom
posthog-code/fix-docs-search-keydown-guard
Jul 31, 2026
Merged

fix(search): guard against key-less keydown events in search bar#1691
christopher-hakkaart merged 6 commits into
masterfrom
posthog-code/fix-docs-search-keydown-guard

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Guards against a TypeError: undefined is not an object (evaluating 'e.key.toLowerCase') thrown from the docs search bar on Safari.

The swizzled src/theme/SearchBar/index.tsx 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 can arrive without a key, so event.key is undefined and the handler throws. Search still works, but the error clutters error tracking.

The fix installs 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. This keeps the fix local to our swizzled component (the repo has no patch-package setup, and the bug lives in a dependency).

Why

A newly-created error-tracking issue surfaced this non-fatal TypeError from the docs.seqera.io search bar on Safari, triggered by stray synthetic keydown events. It doesn't block search or any user flow, but adds noise to error tracking; the fix is a small, safe guard.


Created with PostHog Desktop from this inbox report.

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
@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploy Preview for seqera-docs ready!

Name Link
🔨 Latest commit f7af9b5
🔍 Latest deploy log https://app.netlify.com/projects/seqera-docs/deploys/6a6c25cd870f65000873fd4d
😎 Deploy Preview https://deploy-preview-1691--seqera-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@christopher-hakkaart christopher-hakkaart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this out, and it makes sense. It should help clean up some of the reporting.

@christopher-hakkaart
christopher-hakkaart marked this pull request as ready for review July 31, 2026 00:44
@christopher-hakkaart
christopher-hakkaart merged commit 2f26e92 into master Jul 31, 2026
7 of 8 checks passed
@christopher-hakkaart
christopher-hakkaart deleted the posthog-code/fix-docs-search-keydown-guard branch July 31, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants