From b6f45d0c27fa088e02cb9719e2d908c4dd9ec589 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Tue, 16 Jun 2026 18:40:03 -0700 Subject: [PATCH] Fix scrolling and layout in base ref picker dialog (#5556) Prevent Radix Dialog's scroll lock from canceling mouse wheel events inside the search results list by manually handling wheel events. Also, add flex and max-height constraints to the dialog layout to support clean scrolling behavior. --- .../right-sidebar/SourceControl.tsx | 50 ++++++++++--------- .../src/components/settings/BaseRefPicker.tsx | 29 +++++++++-- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/SourceControl.tsx b/src/renderer/src/components/right-sidebar/SourceControl.tsx index ad591d52e..706772c78 100644 --- a/src/renderer/src/components/right-sidebar/SourceControl.tsx +++ b/src/renderer/src/components/right-sidebar/SourceControl.tsx @@ -5550,8 +5550,8 @@ function SourceControlInner(): React.JSX.Element { /> - - + + {translate( 'auto.components.right.sidebar.SourceControl.476b77745b', @@ -5565,28 +5565,30 @@ function SourceControlInner(): React.JSX.Element { )} - { - if (baseRefOwnedByWorktree && activeWorktreeId) { - void updateWorktreeMeta(activeWorktreeId, { baseRef: ref }) - } else { - void updateRepo(activeRepo.id, { worktreeBaseRef: ref }) - } - setBaseRefDialogOpen(false) - window.setTimeout(() => void refreshBranchCompare(), 0) - }} - onUsePrimary={() => { - if (baseRefOwnedByWorktree && activeWorktreeId) { - void updateWorktreeMeta(activeWorktreeId, { baseRef: undefined }) - } else { - void updateRepo(activeRepo.id, { worktreeBaseRef: undefined }) - } - setBaseRefDialogOpen(false) - window.setTimeout(() => void refreshBranchCompare(), 0) - }} - /> +
+ { + if (baseRefOwnedByWorktree && activeWorktreeId) { + void updateWorktreeMeta(activeWorktreeId, { baseRef: ref }) + } else { + void updateRepo(activeRepo.id, { worktreeBaseRef: ref }) + } + setBaseRefDialogOpen(false) + window.setTimeout(() => void refreshBranchCompare(), 0) + }} + onUsePrimary={() => { + if (baseRefOwnedByWorktree && activeWorktreeId) { + void updateWorktreeMeta(activeWorktreeId, { baseRef: undefined }) + } else { + void updateRepo(activeRepo.id, { worktreeBaseRef: undefined }) + } + setBaseRefDialogOpen(false) + window.setTimeout(() => void refreshBranchCompare(), 0) + }} + /> +
([]) const [isSearchingBaseRefs, setIsSearchingBaseRefs] = useState(false) + const baseRefResultsListRef = useRef(null) + + // Why: Radix Dialog scroll-lock cancels wheel events on in-dialog scroll + // regions, so we scroll the results list manually (same pattern as CommandList). + useEffect(() => { + const el = baseRefResultsListRef.current + if (!el) { + return + } + const onWheel = (event: WheelEvent): void => { + if (el.scrollHeight <= el.clientHeight) { + return + } + event.preventDefault() + el.scrollTop += event.deltaY + } + el.addEventListener('wheel', onWheel, { passive: false }) + return () => el.removeEventListener('wheel', onWheel) + }, [baseRefResults.length]) useEffect(() => { let stale = false @@ -195,7 +213,10 @@ export function BaseRefPicker({ {!isSearchingBaseRefs && baseRefQuery.trim().length >= 2 ? ( baseRefResults.length > 0 ? ( - +
{baseRefResults.map((ref) => (
- +
) : (

{translate(