Fix git panel context menu keybinding jitter#52217
Merged
Veykril merged 3 commits intozed-industries:mainfrom Mar 24, 2026
Merged
Fix git panel context menu keybinding jitter#52217Veykril merged 3 commits intozed-industries:mainfrom
Veykril merged 3 commits intozed-industries:mainfrom
Conversation
auto-merge was automatically disabled
March 24, 2026 11:43
Head branch was pushed to by a user without write access
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.
Context
The git panel's context menu caused visual jitter (flickering/jumping) when opened via right-click on a tracked file. The root cause was in
dispatch_context(): it usedself.focus_handle == focusedto check if the panel itself was directly focused, but when a context menu opened, focus moved to the menu (a child element), causing the"menu"and"ChangesList"key contexts to be dropped. This triggered a re-render with different keybindings, which re-added them, creating a loop of jitter.The fix replaces the direct focus equality check with
self.focus_handle.contains_focused(window, cx), which returnstruewhen any child element (including the context menu) holds focus within the panel's focus tree. This is consistent with how other panels (project panel, outline panel, collab panel) handle focus-based dispatch contexts.Closes #51813
Demo
Before fix:
before_fix.mp4
After fix:
after_fix.mp4
How to Review
This is a small, focused change in a single file:
crates/git_ui/src/git_panel.rs.dispatch_context()method — the old code checked direct focus equality (self.focus_handle == focused), the new code usesself.focus_handle.contains_focused(window, cx)and restructures the conditionals soCommitEditoris checked first viaif/else if.test_dispatch_context_with_focus_states— verifies 4 focus state transitions: commit editor focused, changes list focused, back to commit editor, and back to changes list. Each case asserts the correct key contexts are present/absent.Self-Review Checklist
Release Notes: