-
Notifications
You must be signed in to change notification settings - Fork 715
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
minor fix to <Text> and re-enable unit tests. #790
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome fix for the tests! I had some comments on the deps tho.
packages/vx-text/package.json
Outdated
"@types/react": "*", | ||
"classnames": "^2.2.5", | ||
"lodash": "^4.17.15", | ||
"prop-types": "^15.7.2", | ||
"lodash.memoize": "^4.1.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone through and done this before but had forgot this was intentional, see #66
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ok sure. will revert.
"@types/react": "*", | ||
"classnames": "^2.2.5", | ||
"lodash": "^4.17.15", | ||
"prop-types": "^15.7.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we actually need this because we have a babel plugin that adds proptypes based on the types defined for a component.
this is useful for consumers I think (proptypes complain in dev / in the console), but @hshoff also was surprised by this recently so maybe we could consider removing it througout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!
@@ -176,6 +185,11 @@ class Text extends React.Component<TextProps, TextState> { | |||
const { wordsByLines } = this.state; | |||
const { x, y } = textProps; | |||
|
|||
// Cannot render <text> if x or y is invalid | |||
if (!isValidXOrY(x) || !isValidXOrY(y)) { | |||
return <svg ref={innerRef} x={dx} y={dy} fontSize={textProps.fontSize} style={SVG_STYLE} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think we should return null
or an svg
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about return null but think if at least having the svg may keep the layout from changing if consumer depends on having some element there.
* JSDom does not implement getComputedTextLength() | ||
* so this function add mock implementation for testing. | ||
*/ | ||
export function addMock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
🐛 Bug Fix
NaN
or invalid values are passed asx
ory
🏠 Internal
prop-types
from dependency. (no longer used)lodash.memoize
in dependency ofvx/text
which is smaller than entirelodash
.