Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { invalidateGitBranchQueries } from "@features/git-interaction/utils/gitC
import {
ArrowClockwise,
CaretDown,
Check,
GitBranch,
Plus,
Spinner,
Expand Down Expand Up @@ -175,6 +176,16 @@ export function BranchSelector({

const isDisabled = !!(disabled || !repoPath || cloudStillLoading);
const inputValue = isCloudMode ? (cloudSearchQuery ?? "") : searchQuery;
const trimmedInputValue = inputValue.trim();
const canUseInputBranch =
!isDisabled &&
trimmedInputValue.length > 0 &&
trimmedInputValue !== displayedBranch;

const handleUseInputBranch = () => {
if (!canUseInputBranch) return;
handleBranchChange(trimmedInputValue);
};

return (
<Combobox
Expand Down Expand Up @@ -237,8 +248,46 @@ export function BranchSelector({
<ComboboxInput
placeholder="Search branches..."
showTrigger={false}
onKeyDownCapture={(event) => {
if (
event.key !== "Enter" ||
event.nativeEvent.isComposing ||
!canUseInputBranch
) {
return;
}

// If the combobox already has a highlighted item, let Base UI select it.
if (event.currentTarget.getAttribute("aria-activedescendant")) {
return;
}

event.preventDefault();
event.stopPropagation();
handleUseInputBranch();
}}
Comment thread
thmsobrmlr marked this conversation as resolved.
/>
</div>
<Tooltip content="Use this branch name" side="bottom">
<Button
variant="outline"
size="sm"
disabled={!canUseInputBranch}
aria-label="Use this branch name"
onMouseDown={(event) => {
// Keep focus inside the combobox so the popover doesn't close before click.
event.preventDefault();
event.stopPropagation();
}}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
handleUseInputBranch();
}}
>
<Check size={14} />
</Button>
</Tooltip>
{onRefresh ? (
<Button
variant="outline"
Expand Down
Loading