Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix: Link label not properly centering #486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/link/Link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ export default class Link extends React.Component {
fill: this.props.fontColor,
fontSize: this.props.fontSize,
fontWeight: this.props.fontWeight,
textAnchor: "middle",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For retro-compatibility to move forward with this PR I'll prefer that we allow clients to pass this prop alongside node.color and others. Please refer to the docs and a sample past PR to know what files require an update to make this work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, shouldn't the prop be passed alongside other link props, such as link.fontColor? Similarly, should clients be able to pass the startOffset (which is also currently locked to 50%)? That change seems to be of a similar nature to allowing clients to pass textAnchor as a prop, since it was previously locked to "middle". Glad to combine any or all of these changes as you see fit.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion. Yes it should be link.textAnchor, but the changeset should be similar. Here's a PR that introduced a property in the link for reference

},
};

return (
<g>
<path {...lineProps} id={id} />
{label && (
<text style={{ textAnchor: "middle" }} {...textProps}>
<text {...textProps}>
<textPath href={`#${id}`} startOffset="50%">
{label}
</textPath>
Expand Down