Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tag): allow on:close to work with Svelte 5 #2097

Merged
merged 1 commit into from
Feb 4, 2025
Merged

Conversation

metonym
Copy link
Collaborator

@metonym metonym commented Feb 4, 2025

Fixes #2096

Interestingly, <Tag filter on:close /> does not fire because the forwarded on:click uses the stopPropagation modifier.

Removing it allows the dispatched "close" event to fire. on:close is effectively an alias for on:click, which is only forwarded to the button for a filterable tag.

Expected

Both "click" and "close" should be logged.

<Tag
  filter
  on:click={() => {
    console.log("click");
  }}
  on:close={() => {
    console.log("close");
  }}
>
  Tag
</Tag>

Expected

If the consumer manually stops propagation, "click" is logged but "close" will not. This works in Svelte 5, but not Svelte 4.

<Tag
  filter
  on:click={(e) => {
    e.stopPropagation();
    console.log("click");
  }}
  on:close={() => {
    console.log("close");
  }}
>
  Tag
</Tag>

@metonym metonym merged commit 6e65ef3 into master Feb 4, 2025
3 checks passed
@metonym metonym deleted the fix-tag-close branch February 4, 2025 22:29
@metonym
Copy link
Collaborator Author

metonym commented Feb 4, 2025

Released in v0.87.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Svelte 5 onclose and on:close don't work on Tag
1 participant