feat(viewas): convert ViewAsBar to React component using useHotkeys#112687
Draft
sentry-junior[bot] wants to merge 1 commit intomasterfrom
Draft
feat(viewas): convert ViewAsBar to React component using useHotkeys#112687sentry-junior[bot] wants to merge 1 commit intomasterfrom
sentry-junior[bot] wants to merge 1 commit intomasterfrom
Conversation
Replaces the vanilla JS keydown handler in the superuser 'view as' toolbar with a proper React component that uses `useHotkeys` from `@sentry/scraps/hotkey`. Key changes: - New `ViewAsBar` component at `sentry/components/viewAsBar` - Uses `useHotkeys` with `cmd+`` / `ctrl+`` — suppresses when input/textarea has focus (fixes the Seer code-block collision) - Registered in `SentryInitRenderReactComponent` enum and `COMPONENT_MAP` - Template updated separately in getsentry to use `__onSentryInit` injection Ref: fix/viewas-compound-hotkey (supersedes that branch)
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
Converts the superuser "View As" toolbar from a vanilla JS implementation to a proper React component using
useHotkeysfrom@sentry/scraps/hotkey.This is the sentry-side change. A companion change in
getsentry/getsentryupdatesgetsentry/templates/viewas/header.htmlto use the__onSentryInitinjection pattern instead of inline vanilla JS.Changes
static/app/components/viewAsBar/index.tsx(new)ViewAsBarReact componentuseHotkeyswithcmd+`` /ctrl+`` (changed from bare ``` to avoid collision with code block shortcuts)useHotkeysdefaults — fixes the Seer code-block triple-backtick collisioncsrfTokenas a prop for the Django form submissionstatic/app/types/system.tsxVIEW_AS_BAR = 'ViewAsBar'toSentryInitRenderReactComponentenumstatic/app/bootstrap/processInitQueue.tsxViewAsBarinCOMPONENT_MAPwith lazy importgetsentry changes (apply separately)
The companion
getsentry/getsentrydiff strips the old HTML/CSS/JS fromgetsentry/templates/viewas/header.htmland replaces it with:Testing
Fixes: https://github.com/getsentry/sentry/issues (backtick hotkey collides with Seer code blocks)