Skip to content

Commit a8cbf10

Browse files
committed
Make focusables more like we discussed
- only navigate files, commits, and branches - press "f" to show button key combos - cmd + hotkeys displayed contextually
1 parent e80f192 commit a8cbf10

25 files changed

+1532
-1081
lines changed

apps/desktop/src/components/BranchHeader.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
class="header-wrapper"
6060
use:focusable={{
6161
onAction: () => onclick?.(),
62-
onActive: (value) => (active = value)
62+
onActive: (value) => (active = value),
63+
focusable: true
6364
}}
6465
>
6566
<div

apps/desktop/src/components/BranchList.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
{branchName}
253253
{projectId}
254254
{stackId}
255+
{active}
255256
multipleBranches={branches.length > 1}
256257
isFirstBranchInStack={firstBranch}
257258
isLastBranchInStack={lastBranch}

apps/desktop/src/components/ChromeHeader.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
class:mac={backend.platformName === 'macos'}
115115
data-tauri-drag-region
116116
class:single-branch={singleBranchMode}
117-
use:focusable={{ activate: true }}
117+
use:focusable
118118
>
119119
<div class="chrome-left" data-tauri-drag-region>
120120
<div class="chrome-left-buttons" class:macos={backend.platformName === 'macos'}>

apps/desktop/src/components/ChromeSidebar.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
kind="outline"
5858
onclick={() => goto(workspacePath(projectId))}
5959
width={34}
60+
hotkey="⌘1"
6061
class={['btn-square', isWorkspacePath() && 'btn-active']}
6162
tooltip="Workspace"
6263
{disabled}
@@ -95,6 +96,7 @@
9596
onclick={() => goto(branchesPath(projectId))}
9697
width={34}
9798
class={['btn-square', isBranchesPath() && 'btn-active']}
99+
hotkey="⌘2"
98100
tooltip="Branches"
99101
{disabled}
100102
>
@@ -156,8 +158,8 @@
156158
onclick={() => goto(historyPath(projectId))}
157159
width={34}
158160
class={['btn-square', isHistoryPath() && 'btn-active']}
161+
hotkey="⌘3"
159162
tooltip="Operations history"
160-
tooltipHotkey="⇧⌘H"
161163
{disabled}
162164
>
163165
{#snippet custom()}
@@ -207,6 +209,7 @@
207209
onclick={() => goto(codegenPath(projectId))}
208210
width={34}
209211
class={['btn-square', isCodegenPath() && 'btn-active']}
212+
hotkey="⌘4"
210213
tooltip="Codegen"
211214
tooltipAlign="start"
212215
{disabled}
@@ -451,11 +454,13 @@
451454
}
452455
.bottom__primary-actions {
453456
display: flex;
457+
position: relative;
454458
flex-direction: column;
455459
gap: 8px;
456460
}
457461
.bottom__ghost-actions {
458462
display: flex;
463+
position: relative;
459464
flex-direction: column;
460465
gap: 2px;
461466
}

apps/desktop/src/components/CommitMessageEditor.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
onExitFloatingModeClick={() => {
244244
useFloatingBox.set(false);
245245
}}
246+
onCancel={handleCancel}
246247
>
247248
{@render editorContent()}
248249
</FloatingCommitBox>

apps/desktop/src/components/CommitRow.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
class:disabled
101101
{onclick}
102102
use:focusable={{
103-
onAction: () => onclick?.()
103+
onAction: () => onclick?.(),
104+
focusable: true
104105
}}
105106
>
106107
{#if selected}

apps/desktop/src/components/FileList.svelte

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import { FOCUS_MANAGER } from '@gitbutler/ui/focus/focusManager';
2323
import { focusable } from '@gitbutler/ui/focus/focusable';
2424
25+
import { untrack } from 'svelte';
2526
import type { ConflictEntriesObj } from '$lib/files/conflicts';
2627
2728
type Props = {
@@ -213,9 +214,17 @@
213214
}
214215
return false;
215216
}
216-
const lastAdded = $derived(idSelection.getById(selectionId).lastAdded);
217+
const currentSelection = $derived(idSelection.getById(selectionId));
218+
const lastAdded = $derived(currentSelection.lastAdded);
219+
const lastAddedIndex = $derived($lastAdded?.index);
217220
$effect(() => {
218-
if ($lastAdded) focusManager.focusNthSibling($lastAdded.index);
221+
if (lastAddedIndex) {
222+
untrack(() => {
223+
if (active) {
224+
focusManager.focusNthSibling(lastAddedIndex);
225+
}
226+
});
227+
}
219228
});
220229
</script>
221230

@@ -235,7 +244,10 @@
235244
draggable={draggableFiles}
236245
executable={isExecutable}
237246
showCheckbox={showCheckboxes}
238-
focusableOpts={{ onKeydown: (e) => handleKeyDown(change, idx, e), autoAction: true }}
247+
focusableOpts={{
248+
onKeydown: (e) => handleKeyDown(change, idx, e),
249+
focusable: true
250+
}}
239251
onclick={(e) => {
240252
e.stopPropagation();
241253
selectFilesInList(e, change, changes, idSelection, selectedFileIds, true, idx, selectionId);

apps/desktop/src/components/FloatingCommitBox.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
children: Snippet;
1212
title: string;
1313
onExitFloatingModeClick: () => void;
14+
onCancel?: () => void;
1415
}
1516
16-
const { children, title, onExitFloatingModeClick }: Props = $props();
17+
const { children, title, onExitFloatingModeClick, onCancel }: Props = $props();
1718
1819
const uiState = inject(UI_STATE);
1920
@@ -38,6 +39,7 @@
3839
uiState.global.floatingBoxPosition.set(snapPosition);
3940
}}
4041
dragHandleElement={headerElRef}
42+
{onCancel}
4143
>
4244
<div class="modal-header" bind:this={headerElRef}>
4345
<div class="drag-handle">

apps/desktop/src/components/FocusCursor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
<style lang="postcss">
7474
:global(.focus-cursor) {
75-
z-index: var(--z-blocker);
75+
z-index: var(--z-modal);
7676
position: absolute;
7777
7878
/* Focus outline frame */

apps/desktop/src/components/PushButton.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
multipleBranches: boolean;
3434
isLastBranchInStack?: boolean;
3535
isFirstBranchInStack?: boolean;
36+
active?: boolean;
3637
};
3738
3839
const {
@@ -41,7 +42,8 @@
4142
stackId,
4243
multipleBranches,
4344
isFirstBranchInStack,
44-
isLastBranchInStack
45+
isLastBranchInStack,
46+
active
4547
}: Props = $props();
4648
4749
const stackService = inject(STACK_SERVICE);
@@ -151,6 +153,7 @@
151153
style="neutral"
152154
{loading}
153155
disabled={buttonDisabled}
156+
hotkey={active ? '⌘P' : undefined}
154157
tooltip={getButtonTooltip(
155158
hasThingsToPush,
156159
hasConflicts,

0 commit comments

Comments
 (0)