fix(web): stop throwing when right-clicking an uncached event - #2549
Merged
tyler-dane merged 1 commit intoAug 2, 2026
Merged
Conversation
Right-clicking a grid event whose id isn't in the react-query cache threw an uncaught "Selected event not found" from getSelectedEvent and took down the grid. The DOM id (data-event-id) can legitimately disagree with the cache: unsaved drafts render with draft.clientId, week transitions render from non-cache-backed placeholderData, and optimistically removed events can still be on screen for a frame. Make the miss a no-op — getDraftForEvent returns null and handleContextMenu bails, matching every other findEventInCache caller. Also fall back to the current grid draft when the clicked id matches getGridDraftId(draft), so right-clicking an in-progress draft opens the menu instead of doing nothing. Generated-By: PostHog Code Task-Id: 9ba7ed8a-80a1-49ac-b763-82a2090da9d7
tyler-dane
marked this pull request as ready for review
August 2, 2026 00:51
tyler-dane
deleted the
posthog-self-driving/fixweb-stop-throwing-when-right-clicked-85631e
branch
August 2, 2026 00:51
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
Error("Selected event not found")and took down the grid — an uncaught throw in a core interaction (right-click to open the event menu), not a degraded state.data-event-id) can legitimately disagree with the cache: unsaved drafts render withdraft.clientId(never cached), week transitions render from non-cache-backedplaceholderData, and optimistically removed events can still be on screen for a frame.findEventInCachecall sites that threw; every other caller treats anullresult as normal.getDraftForEventreturnsnullon a miss andhandleContextMenubails out — same shape as the existingif (!draft) returnguard. It also falls back to the current grid draft when the clicked id matchesgetGridDraftId(draft), so right-clicking an in-progress draft opens the menu instead of quietly doing nothing.Simplicity
getSelectedEventwith a singlegetDraftForEventhelper; the call site loses its separateeditGridEventDraft(...)wrapping (now folded into the helper), sohandleContextMenugets simpler, not larger.Automated validation
Independent review
GridEventDraftdirectly (the same objectstartGridDraft/gridEventDraftToGridEventalready consume elsewhere), so no new shape is introduced.Test plan
bun test src/components/ContextMenu/contextMenuLayering.test.tsx(3 pass, incl. the new "ignores a right-click on an event that isn't in the cache")bun run type-checkbiome checkon the changed filesCreated with PostHog Desktop from this inbox report.