fix: ModalContainer modals sometimes stay closed / fix autofill not working after 1 usage

This commit is contained in:
Xylight committed 2026-02-26 17:52:08 -08:00
1 parent 6a88a3baca
commit 38844827d0
4 files changed
+77 -72

No files matched your search

+36 -34
View File
@@ -175,40 +175,42 @@
{#snippet autofillPostModal()}
<svelte:boundary>
{#if form.url}
{#await autofill(new URL(form.url))}
<div class="w-full h-48 grid place-items-center">
<TextLoader>
{$t('form.post.fetching')}
</TextLoader>
</div>
<Button size="lg" color="secondary" onclick={history.back}>
{$t('common.cancel')}
</Button>
{:then url}
{#if !url}
<!--cursed svelte template abuse. don't do this lads-->
{history.back()}
{/if}
<Material color="info" class="space-y-2 h-48">
<h2 class="text-xl font-display font-medium">{url.title}</h2>
<p class="overflow-hidden text-ellipsis">{url.body ?? '...'}</p>
</Material>
<Button
size="lg"
color="primary"
onclick={() => {
autofill({ title: url.title, body: url.body })
history.back()
}}
>
{$t('form.submit')}
</Button>
{:catch err}
<ErrorContainer scope="-1" message={err} />
{/await}
<Switch class="mt-4" bind:checked={settings.forms.autosubmitAutofill}>
{$t('form.post.autosubmit')}
</Switch>
{#key form.url}
{#await autofill(new URL(form.url))}
<div class="w-full h-48 grid place-items-center">
<TextLoader>
{$t('form.post.fetching')}
</TextLoader>
</div>
<Button size="lg" color="secondary" onclick={history.back}>
{$t('common.cancel')}
</Button>
{:then url}
{#if !url}
<!--cursed svelte template abuse. don't do this lads-->
{history.back()}
{/if}
<Material color="info" class="space-y-2 h-48">
<h2 class="text-xl font-display font-medium">{url.title}</h2>
<p class="overflow-hidden text-ellipsis">{url.body ?? '...'}</p>
</Material>
<Button
size="lg"
color="primary"
onclick={() => {
autofill({ title: url.title, body: url.body })
history.back()
}}
>
{$t('form.submit')}
</Button>
{:catch err}
<ErrorContainer scope="-1" message={err} />
{/await}
<Switch class="mt-4" bind:checked={settings.forms.autosubmitAutofill}>
{$t('form.post.autosubmit')}
</Switch>
{/key}
{/if}
</svelte:boundary>
{/snippet}
@@ -161,7 +161,6 @@
}
.post-media-indicator {
/*bg-linear-180 from-zinc-900/0 to-zinc-900/95 h-16 absolute bottom-0 w-full left-0 flex items-end p-2*/
position: absolute;
bottom: 0;
left: 0;
@@ -170,6 +169,8 @@
padding: calc(var(--spacing) * 2);
height: calc(var(--spacing) * 16);
width: 100%;
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;
background-image: linear-gradient(
to bottom,
+38 -36
View File
@@ -4,39 +4,41 @@
import { shownModal } from './modal'
</script>
{#if $shownModal}
<Modal
title={$shownModal.title}
dismissable={$shownModal.dismissable}
ondismissed={() => shownModal.set(undefined)}
open={!!$shownModal}
>
{#if $shownModal.snippet}
{@render $shownModal.snippet?.()}
{/if}
{#if $shownModal.body}
<p>{$shownModal.body}</p>
{/if}
{#if $shownModal.actions}
<div
class="flex items-center gap-2 {$shownModal.actions.length >= 3
? 'flex-col'
: 'flex-row'}"
>
{#each $shownModal.actions as action (action)}
<Button
size="lg"
class="flex-1 w-full"
onclick={action.action}
color={action.type}
>
{#if action.icon}
<Icon src={action.icon} mini size="16" />
{/if}
{action.content}
</Button>
{/each}
</div>
{/if}
</Modal>
{/if}
{#key $shownModal}
{#if $shownModal}
<Modal
title={$shownModal.title}
dismissable={$shownModal.dismissable}
ondismissed={() => shownModal.set(undefined)}
open={!!$shownModal}
>
{#if $shownModal.snippet}
{@render $shownModal.snippet?.()}
{/if}
{#if $shownModal.body}
<p>{$shownModal.body}</p>
{/if}
{#if $shownModal.actions}
<div
class="flex items-center gap-2 {$shownModal.actions.length >= 3
? 'flex-col'
: 'flex-row'}"
>
{#each $shownModal.actions as action (action)}
<Button
size="lg"
class="flex-1 w-full"
onclick={action.action}
color={action.type}
>
{#if action.icon}
<Icon src={action.icon} mini size="16" />
{/if}
{action.content}
</Button>
{/each}
</div>
{/if}
</Modal>
{/if}
{/key}