Migrate TagAddButton to Svelte 5 callback props

This commit is contained in:
Amanda Sternberg 2025-11-20 15:19:53 +01:00
parent dda192f24c
commit d4bdcc8c66
2 changed files with 4 additions and 5 deletions

View file

@ -5,7 +5,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<script lang="ts"> <script lang="ts">
import * as tr from "@generated/ftl"; import * as tr from "@generated/ftl";
import { getPlatformString } from "@tslib/shortcuts"; import { getPlatformString } from "@tslib/shortcuts";
import { createEventDispatcher } from "svelte";
import Icon from "$lib/components/Icon.svelte"; import Icon from "$lib/components/Icon.svelte";
import IconConstrain from "$lib/components/IconConstrain.svelte"; import IconConstrain from "$lib/components/IconConstrain.svelte";
@ -16,10 +15,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let keyCombination: string; export let keyCombination: string;
const dispatch = createEventDispatcher<{ tagappend: null }>(); export let onTagAppend: (() => void) | undefined;
function appendTag() { function appendTag() {
dispatch("tagappend"); if (onTagAppend) onTagAppend();
} }
</script> </script>
@ -43,7 +42,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</span> </span>
</div> </div>
<Shortcut {keyCombination} on:action={() => dispatch("tagappend")} /> <Shortcut {keyCombination} on:action={appendTag} />
<style lang="scss"> <style lang="scss">
.tag-add-button { .tag-add-button {

View file

@ -21,7 +21,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{#if tagsSelected} {#if tagsSelected}
<TagsSelectedButton on:tagselectall on:tagcopy on:tagdelete /> <TagsSelectedButton on:tagselectall on:tagcopy on:tagdelete />
{:else} {:else}
<TagAddButton on:tagappend {keyCombination} /> <TagAddButton {keyCombination} />
{/if} {/if}
{/key} {/key}
</div> </div>