Skip to content

Commit 9b049ea

Browse files
committed
Make keyboard navigation simple
- enter/space to click - flat movement, up/down or left/right
1 parent 93e288a commit 9b049ea

26 files changed

+733
-162
lines changed

apps/desktop/src/components/BranchCommitList.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
lastBranch: boolean;
5353
branchDetails: BranchDetails;
5454
stackingReorderDropzoneManager: ReorderCommitDzFactory;
55+
active?: boolean;
5556
5657
handleUncommit: (commitId: string, branchName: string) => Promise<void>;
5758
startEditingCommitMessage: (branchName: string, commitId: string) => void;
@@ -73,6 +74,7 @@
7374
firstBranch,
7475
lastBranch,
7576
stackingReorderDropzoneManager,
77+
active,
7678
handleUncommit,
7779
startEditingCommitMessage,
7880
handleEditPatch,
@@ -272,7 +274,7 @@
272274
use:focusable={{
273275
id: DefinedFocusable.CommitList,
274276
list: true,
275-
disabled: localAndRemoteCommits.length <= 1
277+
skip: true
276278
}}
277279
>
278280
{#if hasRemoteCommits}
@@ -293,6 +295,7 @@
293295
{first}
294296
{lastCommit}
295297
{selected}
298+
{active}
296299
onclick={() => handleCommitClick(commit.id, true)}
297300
disableCommitActions={false}
298301
/>
@@ -431,6 +434,7 @@
431434
{lastBranch}
432435
{selected}
433436
{tooltip}
437+
{active}
434438
onclick={() => handleCommitClick(commit.id, false)}
435439
disableCommitActions={false}
436440
>

apps/desktop/src/components/BranchHeader.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@
6161
use:focusable={{
6262
id: DefinedFocusable.Branch,
6363
linkToIds: DEFAULT_LINKS,
64-
list: true,
6564
onKeydown: (e) => {
66-
if (e.key === 'Enter' || (!e.metaKey && e.key === 'ArrowRight')) {
65+
if (e.key === 'Enter' || e.key === ' ') {
6766
e.stopPropagation();
6867
onclick?.();
6968
}

apps/desktop/src/components/BranchList.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
stackId?: string;
3434
laneId: string;
3535
branches: BranchDetails[];
36+
active: boolean;
3637
onselect?: () => void;
3738
};
3839
39-
const { projectId, branches, stackId, laneId, onselect }: Props = $props();
40+
const { projectId, branches, stackId, laneId, active, onselect }: Props = $props();
4041
const stackService = inject(STACK_SERVICE);
4142
const uiState = inject(UI_STATE);
4243
const modeService = inject(MODE_SERVICE);
@@ -310,6 +311,7 @@
310311
{branchName}
311312
{branchDetails}
312313
{stackingReorderDropzoneManager}
314+
{active}
313315
{handleUncommit}
314316
{startEditingCommitMessage}
315317
{handleEditPatch}

apps/desktop/src/components/BranchesView.svelte

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,7 @@
383383
</div>
384384

385385
{#if current.commitId || (current.branchName && ((current.inWorkspace && current.stackId) || !current.isTarget)) || current.prNumber}
386-
<div
387-
class="commit-column"
388-
bind:this={commitColumn}
389-
class:non-local-pr={isNonLocalPr}
390-
use:focusable
391-
>
386+
<div class="commit-column" bind:this={commitColumn} class:non-local-pr={isNonLocalPr}>
392387
{#if current.commitId}
393388
<UnappliedCommitView {projectId} commitId={current.commitId} />
394389
<Resizer

apps/desktop/src/components/Chrome.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import ReduxResult from '$components/ReduxResult.svelte';
77
import { PROJECTS_SERVICE } from '$lib/project/projectsService';
88
import { inject } from '@gitbutler/core/context';
9+
import { focusable } from '@gitbutler/ui/focus/focusable';
910
import type { Snippet } from 'svelte';
1011
1112
const {
@@ -20,9 +21,9 @@
2021

2122
<ReduxResult {projectId} result={projectResult.current}>
2223
{#snippet children(project, { projectId })}
23-
<div class="chrome">
24+
<div class="chrome" use:focusable={{ list: true, activate: true }}>
2425
<ChromeHeader {projectId} projectTitle={project.title} actionsDisabled={sidebarDisabled} />
25-
<div class="chrome-body">
26+
<div class="chrome-body" use:focusable={{ skip: true }}>
2627
<EnsureAuthorInfo {projectId} />
2728
<ChromeSidebar {projectId} disabled={sidebarDisabled} />
2829
<div class="chrome-content">

apps/desktop/src/components/ChromeHeader.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
TestId,
2424
Tooltip
2525
} from '@gitbutler/ui';
26+
import { focusable } from '@gitbutler/ui/focus/focusable';
2627
2728
type Props = {
2829
projectId: string;
@@ -113,6 +114,7 @@
113114
class:mac={backend.platformName === 'macos'}
114115
data-tauri-drag-region
115116
class:single-branch={singleBranchMode}
117+
use:focusable={{ activate: true }}
116118
>
117119
<div class="chrome-left" data-tauri-drag-region>
118120
<div class="chrome-left-buttons" class:macos={backend.platformName === 'macos'}>

apps/desktop/src/components/ChromeSidebar.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
Icon,
2929
TestId
3030
} from '@gitbutler/ui';
31+
import { focusable } from '@gitbutler/ui/focus/focusable';
3132
3233
import { slide } from 'svelte/transition';
3334
@@ -45,7 +46,7 @@
4546
const { openGeneralSettings, openProjectSettings } = useSettingsModal();
4647
</script>
4748

48-
<div class="sidebar">
49+
<div class="sidebar" use:focusable>
4950
<div class="top">
5051
<div>
5152
{#if isWorkspacePath()}

apps/desktop/src/components/CommitRow.svelte

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@
7474
isOpen,
7575
disabled,
7676
hasConflicts,
77+
active,
7778
onclick,
7879
menu,
7980
...args
8081
}: Props = $props();
8182
82-
let active = $state(false);
8383
let container = $state<HTMLDivElement>();
8484
</script>
8585

@@ -106,13 +106,12 @@
106106
onKeydown: (e) => {
107107
if (disabled) return false;
108108

109-
if (e.key === 'Enter' || e.key === ' ' || (!e.metaKey && e.key === 'ArrowRight')) {
109+
if (e.key === 'Enter' || e.key === ' ') {
110110
e.stopPropagation();
111111
onclick?.();
112112
return true;
113113
}
114-
},
115-
onActive: (value) => (active = value)
114+
}
116115
}}
117116
>
118117
{#if selected}

apps/desktop/src/components/Drawer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@
8383
class:transparent
8484
class:grow
8585
class:noshrink
86-
use:focusable={{ list: true }}
8786
>
8887
<div
8988
bind:this={headerDiv}
9089
class="drawer-header"
9190
class:bottom-border={!$collapsed}
9291
bind:clientHeight={headerHeight}
92+
use:focusable
9393
>
9494
{#if !disableFold}
9595
<button

apps/desktop/src/components/FileList.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
});
177177
178178
function handleKeyDown(change: TreeChange, idx: number, e: KeyboardEvent) {
179-
if (e.key === 'Enter' || e.key === 'l') {
179+
if (e.key === 'Enter' || e.key === ' ' || e.key === 'l') {
180180
e.stopPropagation();
181181
selectFilesInList(e, change, changes, idSelection, true, idx, selectionId);
182182
onselect?.();
@@ -251,6 +251,7 @@
251251
use:focusable={{
252252
id: DefinedFocusable.FileList,
253253
list: true,
254+
skip: true,
254255
onActive: (value) => (active = value)
255256
}}
256257
>

0 commit comments

Comments
 (0)