[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>
This commit is contained in:
parent
1390b1dc9e
commit
9fb20915e8
2 changed files with 44 additions and 13 deletions
|
@ -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>
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue