fix(search): guard against key-less keydown events in search bar - #1691
Merged
christopher-hakkaart merged 6 commits intoJul 31, 2026
Merged
Conversation
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
✅ Deploy Preview for seqera-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
christopher-hakkaart
approved these changes
Jul 28, 2026
christopher-hakkaart
left a comment
Member
There was a problem hiding this comment.
Checked this out, and it makes sense. It should help clean up some of the reporting.
christopher-hakkaart
approved these changes
Jul 31, 2026
christopher-hakkaart
marked this pull request as ready for review
July 31, 2026 00:44
christopher-hakkaart
deleted the
posthog-code/fix-docs-search-keydown-guard
branch
July 31, 2026 04:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsxusesuseDocSearchKeyboardEventsfromtypesense-docsearch-react, which registers a globalkeydownlistener that callsevent.key.toLowerCase()with no guard. Synthetic keydown events dispatched by password managers, autofill, or browser extensions can arrive without akey, soevent.keyisundefinedand the handler throws. Search still works, but the error clutters error tracking.The fix installs a capture-phase
keydownlistener that runs before the upstream handler and swallows malformed, key-less events viastopImmediatePropagation(). A real user keystroke always carries akey, 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
TypeErrorfrom 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.