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> </script>
<PopupMenu bind:this={popupMenu} let:item> <PopupMenu bind:this={popupMenu} let:item let:dismiss>
<ContextMenu> <ContextMenu>
<ContextMenuSection> <ContextMenuSection>
{#if item.files !== undefined} {#if item.files !== undefined}
{#if containsBinaryFiles(item)} {#if containsBinaryFiles(item)}
<ContextMenuItem label="Discard file (Binary files not yet supported)" disabled /> <ContextMenuItem label="Discard file (Binary files not yet supported)" disabled />
{:else} {:else}
<ContextMenuItem label="Discard file" on:click={() => confirmationModal.show(item)} /> <ContextMenuItem
label="Discard file"
on:click={() => {
confirmationModal.show(item);
dismiss();
}}
/>
{/if} {/if}
{/if} {/if}
</ContextMenuSection> </ContextMenuSection>

View File

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

View File

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