-
-
Notifications
You must be signed in to change notification settings - Fork 120
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: add default penColor
prop
#107
base: main
Are you sure you want to change the base?
Conversation
penColor
prop
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.
penColor={undefined}
3. If you comment out the
penColor
prop, you will not encounter the issue.
This seems contrived to me
might be passed as undefined during parent component re-renders.
I'm not sure this should be resolved here, but rather in the parent component. You could technically apply a similar fix for every other inherited prop, so that does not seem like good precedent. Special casing is a rabbit hole.
There were also no tests added here despite the special case.
* In such cases, the underlying signature_pad assigns fillColor as undefined, preventing drawing. | ||
* Ideally, this issue should be fixed in the signature_pad library, but since we are using an older version, we need to handle it here. | ||
*/ | ||
penColor: 'black', |
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.
This seems like it could be a breaking change
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.
Not a breaking change.
This is inspired from underlying library: https://github.com/szimek/signature_pad/blob/master/src/signature_pad.ts#L96
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.
Or rather, the 2.x version: https://github.com/szimek/signature_pad/blob/2171e510b74362a8dd7c8e7fc77a142f16a4aed1/src/signature_pad.js#L24
Although yes, in both cases, upstream does not prevent you from assigning undefined
. As a wrapper, I think following that behavior and not deviating from it is appropriate.
Summary
This PR addresses an issue where the penColor prop might be passed as undefined during parent component re-renders. This causes the underlying signature_pad library to set the fillColor as undefined, preventing any further drawing on the canvas. To resolve this, we are adding penColor as a default prop with a value of 'black'.
Changes
Added penColor to defaultProps with a default value of 'black'.
How to reproduce the issue
Clear
text and try to draw some again and it won't work.penColor
prop, you will not encounter the issue.