Skip to content

Commit dd68a45

Browse files
committed
Simplify focusables further
- `list` has been renamed to `vertical` - `skip` is now inferred `vertical` or having children - `DefinedFocusable` has been removed completely
1 parent dfba71d commit dd68a45

17 files changed

+160
-400
lines changed

apps/desktop/src/components/BranchCommitList.svelte

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import { inject } from '@gitbutler/core/context';
3636
import { persisted } from '@gitbutler/shared/persisted';
3737
import { Button, Modal, RadioButton, TestId } from '@gitbutler/ui';
38-
import { DefinedFocusable } from '@gitbutler/ui/focus/focusManager';
3938
import { focusable } from '@gitbutler/ui/focus/focusable';
4039
import { getTimeAgo } from '@gitbutler/ui/utils/timeAgo';
4140
import { isDefined } from '@gitbutler/ui/utils/typeguards';
@@ -269,14 +268,7 @@
269268
{@render commitReorderDz(stackingReorderDropzoneManager.top(branchName))}
270269

271270
{#if hasCommits || hasRemoteCommits}
272-
<div
273-
class="commit-list hide-when-empty"
274-
use:focusable={{
275-
id: DefinedFocusable.CommitList,
276-
list: true,
277-
skip: true
278-
}}
279-
>
271+
<div class="commit-list hide-when-empty" use:focusable={{ vertical: true }}>
280272
{#if hasRemoteCommits}
281273
{#each upstreamOnlyCommits as commit, i (commit.id)}
282274
{@const first = i === 0}

apps/desktop/src/components/BranchHeader.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import BranchHeaderIcon from '$components/BranchHeaderIcon.svelte';
55
import BranchLabel from '$components/BranchLabel.svelte';
66
import { TestId } from '@gitbutler/ui';
7-
import { DEFAULT_LINKS, DefinedFocusable } from '@gitbutler/ui/focus/focusManager';
87
import { focusable } from '@gitbutler/ui/focus/focusable';
98
import { slide } from 'svelte/transition';
109
import type iconsJson from '@gitbutler/ui/data/icons.json';
@@ -59,8 +58,6 @@
5958
<div
6059
class="header-wrapper"
6160
use:focusable={{
62-
id: DefinedFocusable.Branch,
63-
linkToIds: DEFAULT_LINKS,
6461
onKeydown: (e) => {
6562
if (e.key === 'Enter' || e.key === ' ') {
6663
e.stopPropagation();

apps/desktop/src/components/BranchesView.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
<div
196196
bind:this={branchViewLeftEl}
197197
class="branches-view__left"
198-
use:focusable={{ list: true }}
198+
use:focusable={{ vertical: true }}
199199
>
200200
<BranchesListGroup title="Current workspace target">
201201
<!-- TODO: We need an API for `commitsCount`! -->
@@ -283,7 +283,7 @@
283283

284284
<div class="branches-view__right">
285285
<div class="right-wrapper hide-native-scrollbar dotted-pattern" bind:this={rightWrapper}>
286-
<div class="branch-column" bind:this={branchColumn} use:focusable={{ list: true }}>
286+
<div class="branch-column" bind:this={branchColumn} use:focusable={{ vertical: true }}>
287287
<!-- Apply branch -->
288288
{#if !inWorkspaceOrTargetBranch && someBranchSelected && !isNonLocalPr}
289289
{@const doesNotHaveLocalTooltip = current.hasLocal
@@ -339,14 +339,14 @@
339339
{/if}
340340

341341
{#if isTargetBranch}
342-
<div class="commits" use:focusable={{ list: true }}>
342+
<div class="commits" use:focusable={{ vertical: true }}>
343343
<TargetCommitList {projectId} />
344344
</div>
345345
{/if}
346346

347347
{#if !isTargetBranch && someBranchSelected && !isNonLocalPr}
348348
<ConfigurableScrollableContainer>
349-
<div class="commits with-padding" use:focusable={{ list: true }}>
349+
<div class="commits with-padding" use:focusable={{ vertical: true }}>
350350
{#if current.stackId}
351351
<BranchesViewStack {projectId} stackId={current.stackId} {onerror} />
352352
{:else if current.branchName}
@@ -362,7 +362,7 @@
362362
{/if}
363363

364364
{#if isNonLocalPr && current.prNumber}
365-
<div class="commits" use:focusable={{ list: true }}>
365+
<div class="commits" use:focusable={{ vertical: true }}>
366366
<BranchesViewPr
367367
bind:this={prBranch}
368368
{projectId}

apps/desktop/src/components/Chrome.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
<ReduxResult {projectId} result={projectResult.current}>
2323
{#snippet children(project, { projectId })}
24-
<div class="chrome" use:focusable={{ list: true, activate: true }}>
24+
<div class="chrome" use:focusable={{ vertical: true, activate: true }}>
2525
<ChromeHeader {projectId} projectTitle={project.title} actionsDisabled={sidebarDisabled} />
26-
<div class="chrome-body" use:focusable={{ skip: true }}>
26+
<div class="chrome-body" use:focusable>
2727
<EnsureAuthorInfo {projectId} />
2828
<ChromeSidebar {projectId} disabled={sidebarDisabled} />
2929
<div class="chrome-content">

apps/desktop/src/components/CommitRow.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import CommitTitle from '$components/CommitTitle.svelte';
44
import { type CommitStatusType } from '$lib/commits/commit';
55
import { Avatar, Icon, TestId } from '@gitbutler/ui';
6-
import { DEFAULT_LINKS, DefinedFocusable } from '@gitbutler/ui/focus/focusManager';
76
import { focusable } from '@gitbutler/ui/focus/focusable';
87
98
import { slide } from 'svelte/transition';
@@ -101,8 +100,6 @@
101100
class:disabled
102101
{onclick}
103102
use:focusable={{
104-
id: DefinedFocusable.Commit,
105-
linkToIds: DEFAULT_LINKS,
106103
onKeydown: (e) => {
107104
if (disabled) return false;
108105

apps/desktop/src/components/FileList.svelte

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import { chunk } from '$lib/utils/array';
2020
import { inject, injectOptional } from '@gitbutler/core/context';
2121
import { FileListItem } from '@gitbutler/ui';
22-
import { DEFAULT_LINKS, DefinedFocusable } from '@gitbutler/ui/focus/focusManager';
2322
import { focusable } from '@gitbutler/ui/focus/focusable';
2423
2524
import type { ConflictEntriesObj } from '$lib/files/conflicts';
@@ -232,11 +231,7 @@
232231
draggable={draggableFiles}
233232
executable={!!isExecutable}
234233
showCheckbox={showCheckboxes}
235-
focusableOpts={{
236-
id: DefinedFocusable.FileItem,
237-
linkToIds: DEFAULT_LINKS,
238-
onKeydown: (e) => handleKeyDown(change, idx, e)
239-
}}
234+
focusableOpts={{ onKeydown: (e) => handleKeyDown(change, idx, e) }}
240235
onclick={(e) => {
241236
e.stopPropagation();
242237
selectFilesInList(e, change, changes, idSelection, true, idx, selectionId);
@@ -249,9 +244,7 @@
249244
<div
250245
class="file-list"
251246
use:focusable={{
252-
id: DefinedFocusable.FileList,
253-
list: true,
254-
skip: true,
247+
vertical: true,
255248
onActive: (value) => (active = value)
256249
}}
257250
>

apps/desktop/src/components/MainViewport.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ the window, then enlarge it and retain the original widths of the layout.
163163
bind:this={previewDiv}
164164
style:width={finalPreviewWidth + 'rem'}
165165
style:min-width={previewMinWidth + 'rem'}
166-
use:focusable={{ list: true }}
166+
use:focusable={{ vertical: true }}
167167
>
168168
<div class="left-sideview-content dotted-pattern">
169169
{@render preview()}

apps/desktop/src/components/SettingsModalLayout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
{/if}
6262
</div>
6363

64-
<section class="page-view" use:focusable={{ list: true }}>
64+
<section class="page-view" use:focusable={{ vertical: true }}>
6565
<ConfigurableScrollableContainer>
6666
<div class="page-view__content">
6767
{@render content({ currentPage })}

apps/desktop/src/components/SnapshotCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
class="snapshot-card show-restore-on-hover"
180180
class:restored-snapshot={isRestoreSnapshot || isWithinRestore}
181181
use:focusable={{
182-
list: true
182+
vertical: true
183183
}}
184184
>
185185
<div class="snapshot-right-container">

apps/desktop/src/components/StackView.svelte

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import { persistWithExpiration } from '@gitbutler/shared/persisted';
3232
3333
import { Button, FileViewHeader, Icon, TestId } from '@gitbutler/ui';
34-
import { DefinedFocusable } from '@gitbutler/ui/focus/focusManager';
3534
import { focusable } from '@gitbutler/ui/focus/focusable';
3635
import { intersectionObserver } from '@gitbutler/ui/utils/intersectionObserver';
3736
import { fly } from 'svelte/transition';
@@ -429,7 +428,7 @@
429428
root: lanesSrollableEl
430429
}
431430
}}
432-
use:focusable={{ skip: true }}
431+
use:focusable
433432
>
434433
{#if !isCommitting}
435434
<div class="drag-handle" data-remove-from-panning data-drag-handle draggable="true">
@@ -442,7 +441,7 @@
442441
class="stack-view"
443442
class:details-open={isDetailsViewOpen}
444443
style:width="{$persistedStackWidth}rem"
445-
use:focusable={{ list: true, onActive: (value) => (active = value) }}
444+
use:focusable={{ vertical: true, onActive: (value) => (active = value) }}
446445
bind:this={stackViewEl}
447446
>
448447
<ReduxResult {projectId} result={branchesResult.current}>
@@ -452,10 +451,7 @@
452451
<div
453452
class="assignments-wrap"
454453
class:assignments__empty={changes.current.length === 0 && !isCommitting}
455-
use:focusable={{
456-
id: DefinedFocusable.Assignments,
457-
list: true
458-
}}
454+
use:focusable={{ vertical: true }}
459455
>
460456
<div
461457
class="worktree-wrap"
@@ -556,7 +552,7 @@
556552
bind:this={compactDiv}
557553
data-details={stackId}
558554
style:right="{DETAILS_RIGHT_PADDING_REM}rem"
559-
use:focusable={{ list: true }}
555+
use:focusable={{ vertical: true }}
560556
>
561557
<div class="details-view__inner">
562558
<!-- TOP SECTION: Branch/Commit Details (no resizer) -->

0 commit comments

Comments
 (0)