fix: hunk and file context menu now correctly dismiss

This commit is contained in:
Meesayen 2024-02-19 14:03:44 +01:00 committed by Mattias Granlund
parent f36ba52b27
commit de7d869411
3 changed files with 21 additions and 7 deletions

View File

@ -21,14 +21,20 @@
}
</script>
<PopupMenu bind:this={popupMenu} let:item>
<PopupMenu bind:this={popupMenu} let:item let:dismiss>
<ContextMenu>
<ContextMenuSection>
{#if item.files !== undefined}
{#if containsBinaryFiles(item)}
<ContextMenuItem label="Discard file (Binary files not yet supported)" disabled />
{:else}
<ContextMenuItem label="Discard file" on:click={() => confirmationModal.show(item)} />
<ContextMenuItem
label="Discard file"
on:click={() => {
confirmationModal.show(item);
dismiss();
}}
/>
{/if}
{/if}
</ContextMenuSection>

View File

@ -16,17 +16,25 @@
}
</script>
<PopupMenu bind:this={popupMenu} let:item>
<PopupMenu bind:this={popupMenu} let:item let:dismiss>
<ContextMenu>
<ContextMenuSection>
{#if item.hunk !== undefined}
<ContextMenuItem label="Discard" on:click={() => branchController.unapplyHunk(item.hunk)} />
<ContextMenuItem
label="Discard"
on:click={() => {
branchController.unapplyHunk(item.hunk);
dismiss();
}}
/>
{/if}
{#if item.lineNumber}
<ContextMenuItem
label="Open in VS Code"
on:click={() =>
projectPath && open(`vscode://file${projectPath}/${filePath}:${item.lineNumber}`)}
on:click={() => {
projectPath && open(`vscode://file${projectPath}/${filePath}:${item.lineNumber}`);
dismiss();
}}
/>
{/if}
</ContextMenuSection>

View File

@ -55,7 +55,7 @@
use:clickOutside={{ handler: () => onDismiss() }}
style="position: absolute; top:{pos.y}px; left:{pos.x}px"
>
<slot {item} />
<slot {item} dismiss={onDismiss} />
</div>
{/if}