Skip to content

Commit

Permalink
Fix: Bug preventing avatar src from clearing (huntabyte#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Oct 21, 2023
1 parent 4b00484 commit 30ed8d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-hairs-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

- Fix: Bug preventing avatar `src` from clearing
2 changes: 1 addition & 1 deletion src/lib/bits/avatar/components/AvatarImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export let alt: $$Props["alt"] = undefined;
export let asChild = false;
const image = ctx.getImage(src).elements.image;
$: image = ctx.getImage(src).elements.image;
</script>

{#if asChild}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/bits/avatar/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function set(props: CreateAvatarProps) {

function getImage(src: string | undefined | null = "") {
const avatar = getContext<AvatarReturn>(NAME);
if (src) {
if (!src) {
avatar.options.src.set("");
} else {
avatar.options.src.set(src);
}
return avatar;
Expand Down

0 comments on commit 30ed8d5

Please sign in to comment.