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

fix(@visx/text) Bad size measurements in Firefox #1175

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions packages/visx-annotation/src/components/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default function Label({
)}
{title && (
<Text
innerRef={titleRef}
innerTextRef={titleRef}
fill={fontColor}
verticalAnchor="start"
x={padding.left + (titleProps?.textAnchor === 'middle' ? innerWidth / 2 : 0)}
Expand All @@ -238,7 +238,7 @@ export default function Label({
)}
{subtitle && (
<Text
innerRef={subtitleRef}
innerTextRef={subtitleRef}
fill={fontColor}
verticalAnchor="start"
x={padding.left + (subtitleProps?.textAnchor === 'middle' ? innerWidth / 2 : 0)}
Expand Down
3 changes: 2 additions & 1 deletion packages/visx-text/src/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function Text(props: TextProps) {
dy = 0,
textAnchor = 'start',
innerRef,
innerTextRef,
verticalAnchor,
angle,
lineHeight = '1em',
Expand All @@ -28,7 +29,7 @@ export default function Text(props: TextProps) {
return (
<svg ref={innerRef} x={dx} y={dy} fontSize={fontSize} style={SVG_STYLE}>
{wordsByLines.length > 0 ? (
<text transform={transform} {...textProps} textAnchor={textAnchor}>
<text ref={innerTextRef} transform={transform} {...textProps} textAnchor={textAnchor}>
{wordsByLines.map((line, index) => (
<tspan key={index} x={x} dy={index === 0 ? startDy : lineHeight}>
{line.words.join(' ')}
Expand Down
2 changes: 2 additions & 0 deletions packages/visx-text/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type OwnProps = {
style?: React.CSSProperties;
/** Ref passed to the Text SVG element. */
innerRef?: React.Ref<SVGSVGElement>;
/** Ref passed to the Text text element */
innerTextRef?: React.Ref<SVGTextElement>;
/** x position of the text. */
x?: string | number;
/** y position of the text. */
Expand Down