diff options
author | dan <dan.abramov@gmail.com> | 2024-04-13 12:19:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 12:19:21 +0100 |
commit | 9fb20915e890be0993c15ad19b59105b78cf8f12 (patch) | |
tree | 5428a2f5c2eb93fa116af1afe6c71bfbc0a86f44 /bskyembed/src/components | |
parent | 1390b1dc9e35aafda328877c46e90860c6268453 (diff) | |
download | voidsky-9fb20915e890be0993c15ad19b59105b78cf8f12.tar.zst |
[Embed] Don't reuse DOM when changing embed (#3530)
* Don't reuse DOM when changing embed * add skeleton loading state 💀 * autoselect text --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
Diffstat (limited to 'bskyembed/src/components')
-rw-r--r-- | bskyembed/src/components/container.tsx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bskyembed/src/components/container.tsx b/bskyembed/src/components/container.tsx index a96addc8c..5b1b2b7fb 100644 --- a/bskyembed/src/components/container.tsx +++ b/bskyembed/src/components/container.tsx @@ -8,7 +8,7 @@ export function Container({ href, }: { children: ComponentChildren - href: string + href?: string }) { const ref = useRef<HTMLDivElement>(null) const prevHeight = useRef(0) @@ -39,7 +39,7 @@ export function Container({ ref={ref} className="w-full bg-white hover:bg-neutral-50 relative transition-colors max-w-[600px] min-w-[300px] flex border rounded-xl" onClick={() => { - if (ref.current) { + if (ref.current && href) { // forwardRef requires preact/compat - let's keep it simple // to keep the bundle size down const anchor = ref.current.querySelector('a') @@ -48,7 +48,7 @@ export function Container({ } } }}> - <Link href={href} /> + {href && <Link href={href} />} <div className="flex-1 px-4 pt-3 pb-2.5">{children}</div> </div> ) |