fix(tooltip): pass lineHeight from style to label component (#2908) - #3088
Open
ErfanBagheri404 wants to merge 1 commit into
Open
fix(tooltip): pass lineHeight from style to label component (#2908)#3088ErfanBagheri404 wants to merge 1 commit into
ErfanBagheri404 wants to merge 1 commit into
Conversation
`VictoryLabel` reads `lineHeight` from its `props.lineHeight` to calculate inter-line spacing (dy between tspans). The tooltip's `getLabelProps` only forwarded `style`, so the label always fell back to the default `lineHeight: 1`, even when the theme supplied a `tooltip.style.lineHeight` (e.g. for a larger flyout). Extract `lineHeight` from the evaluated `style` object and pass it as a dedicated prop, consistent with how other label props (textAnchor, angle, etc.) are forwarded. Closes FormidableLabs#2908
|
@ErfanBagheri404 is attempting to deploy a commit to the Nearform Team on Vercel. A member of the Team first needs to authorize it. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VictoryLabelreadslineHeightfromprops.lineHeightto calculate inter-line spacing (dy between tspans). The tooltip'sgetLabelPropsonly forwardedstyle, so the label always fell back to the defaultlineHeight: 1, even when the theme supplied atooltip.style.lineHeight.Root cause
VictoryTooltip.getLabelPropspassedstyleto the label component, butVictoryLabelreadslineHeightfrom a dedicatedprops.lineHeight(line 157 in victory-label.tsx), not fromstyle.lineHeight. With no explicitlineHeightprop, it defaults to[1], so all lines stack tight regardless of the theme setting.Fix
Extract
lineHeightfrom the evaluatedstyleobject ingetLabelPropsand pass it as a dedicated prop. This is consistent with how other label props (textAnchor,angle) are already forwarded.Test
Added a test that renders a multiline tooltip label with
style: { lineHeight: 2, fontSize: 12 }and verifies the second tspan's dy is greater than 0 (reflecting the multiplier). All 6 tests pass.Closes #2908