Default rx.link href to # so underline prop works (#4509)

This commit is contained in:
Elijah Ahianyo 2024-12-10 17:14:29 +00:00 committed by GitHub
parent 4ecb0b81ce
commit 05b791653e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -77,13 +77,14 @@ class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap):
Component: The link component
"""
props.setdefault(":hover", {"color": color("accent", 8)})
href = props.get("href")
is_external = props.pop("is_external", None)
if is_external is not None:
props["target"] = cond(is_external, "_blank", "")
if props.get("href") is not None:
if href is not None:
if not len(children):
raise ValueError("Link without a child will not display")
@ -101,6 +102,9 @@ class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap):
as_child=True,
**props,
)
else:
props["href"] = "#"
return super().create(*children, **props)