only show hunk line grab cursor if dragging is enabled

This commit is contained in:
Andreas Skielboe 2024-02-16 15:37:17 +01:00 committed by Kiril Videlov
parent 913d4b0eeb
commit 68d9de295e
2 changed files with 6 additions and 4 deletions

View File

@ -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'}
>
<span class="selectable-wrapper" data-no-drag>
{@html toTokens(line.content).join('')}
@ -82,9 +84,6 @@
.line {
flex-grow: 1;
&:not(.readonly) {
cursor: grab;
}
}
.code-line__numbers-line {

View File

@ -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}