You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
dcc.Link: Use href as children if no children are defined #772
With HTML anchors, users are forced to provide a displayed content for the anchor, which can be as simple as the href itself..
<a href='myurl'>myurl</a>
1:1 correspondance in dcc.Link forces users to do the same thing:
dcc.Link(
href='myurl',
children=['myurl']
)
Defaulting to href for inner content if no children is defined provides a default behavior that will be acceptable in certain situations and will simplify usage.
It's possible to use anything as a dcc.Link child and the whole thing becomes clickable, so while href is a string and can be used safely as a child, the same can't be said about children.
Yes. But it lends itself to a if..else.. logic that can be confusing for a user. The href being guaranteed to be there and to be a string, it does not suffer from the same limitations / branching. Not opposed per-say, just want to make sure we agree on the limitations / logic leakage if we decide to support it.
Side-note: href is not currently required. A dcc.Link without href makes no sense, I propose to mark it as isRequired / the old behavior being considered a bug, not a breaking change.
Fair enough - and it could be confusing if you start with just children and want to switch to different text/elements - you have to make two changes: move the children string into href and then provide the new children. Then we can also do #773 🎉
Activity
alexcjohnson commentedon Mar 11, 2020
Perhaps the other way as well, use
childrenashref- that way you can dodcc.Link(myurl)and it'll behave reasonably.Marc-Andre-Rivet commentedon Mar 11, 2020
It's possible to use anything as a dcc.Link child and the whole thing becomes clickable, so while href is a string and can be used safely as a child, the same can't be said about children.
alexcjohnson commentedon Mar 11, 2020
sure, but if
childrenhappens to be just a string, we might as well copy it back tohref.Marc-Andre-Rivet commentedon Mar 11, 2020
Yes. But it lends itself to a
if..else..logic that can be confusing for a user. Thehrefbeing guaranteed to be there and to be a string, it does not suffer from the same limitations / branching. Not opposed per-say, just want to make sure we agree on the limitations / logic leakage if we decide to support it.Side-note:
hrefis not currently required. Adcc.Linkwithouthrefmakes no sense, I propose to mark it asisRequired/ the old behavior being considered a bug, not a breaking change.alexcjohnson commentedon Mar 11, 2020
Fair enough - and it could be confusing if you start with just
childrenand want to switch to different text/elements - you have to make two changes: move thechildrenstring intohrefand then provide the newchildren. Then we can also do #773 🎉