From 68d9de295ed062378b6eb626a4ce76a8355e54af Mon Sep 17 00:00:00 2001 From: Andreas Skielboe Date: Fri, 16 Feb 2024 15:37:17 +0100 Subject: [PATCH] only show hunk line grab cursor if dragging is enabled --- gitbutler-ui/src/lib/components/HunkLine.svelte | 5 ++--- gitbutler-ui/src/lib/components/HunkViewer.svelte | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gitbutler-ui/src/lib/components/HunkLine.svelte b/gitbutler-ui/src/lib/components/HunkLine.svelte index 40fbed893..d2c59ad9c 100644 --- a/gitbutler-ui/src/lib/components/HunkLine.svelte +++ b/gitbutler-ui/src/lib/components/HunkLine.svelte @@ -11,6 +11,7 @@ export let selectable: boolean = false; export let selected: boolean = true; export let readonly: boolean = false; + export let draggingDisabled: boolean = false; const dispatch = createEventDispatcher<{ selected: boolean }>(); @@ -63,6 +64,7 @@ class:readonly class:diff-line-deletion={sectionType === SectionType.RemovedLines} class:diff-line-addition={sectionType === SectionType.AddedLines} + style:cursor={draggingDisabled ? 'default' : 'grab'} > {@html toTokens(line.content).join('')} @@ -82,9 +84,6 @@ .line { flex-grow: 1; - &:not(.readonly) { - cursor: grab; - } } .code-line__numbers-line { diff --git a/gitbutler-ui/src/lib/components/HunkViewer.svelte b/gitbutler-ui/src/lib/components/HunkViewer.svelte index 2c5f212ec..3723724f1 100644 --- a/gitbutler-ui/src/lib/components/HunkViewer.svelte +++ b/gitbutler-ui/src/lib/components/HunkViewer.svelte @@ -43,6 +43,8 @@ $: popupMenu = updateContextMenu(filePath); + $: draggingDisabled = readonly || isUnapplied || section.hunk.locked || !branchId; + onDestroy(() => { if (popupMenu) { popupMenu.$destroy(); @@ -55,7 +57,7 @@ role="cell" use:draggable={{ ...draggableHunk(branchId, section.hunk), - disabled: readonly || isUnapplied || section.hunk.locked || !branchId + disabled: draggingDisabled }} on:contextmenu|preventDefault class="hunk" @@ -72,6 +74,7 @@ {readonly} {minWidth} {selectable} + {draggingDisabled} selected={$selectedOwnership?.containsHunk(hunk.filePath, hunk.id)} on:selected={(e) => onHunkSelected(hunk, e.detail)} sectionType={subsection.sectionType}