-
Notifications
You must be signed in to change notification settings - Fork 375
Charts - add legendAllowWrap callback #8706
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
Charts - add legendAllowWrap callback #8706
Conversation
|
Preview: https://patternfly-react-pr-8706.surge.sh A11y report: https://patternfly-react-pr-8706-a11y.surge.sh |
e4bd433 to
97090c7
Compare
97090c7 to
ed16f7f
Compare
nicolethoen
left a comment
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.
Looks like these changes are causing github to highlight some lint errors - visible in this PR.
they read like
React Hook useEffect has missing dependencies: 'getLegend', 'legendAllowWrap', 'legendAllowWrapCallback', and 'theme'. Either include them or remove the dependency array. If 'legendAllowWrapCallback' changes too often, find the parent component that defines it and wrap that definition in useCallback
I think this implies there are a few best practices being violated (and we have issues open in the react backlog to update the linting in the pf-react project so hopefully we will catch these violations ourself in the near future.
|
@nicolethoen I've fixed the lint warnings. |
wise-king-sullyman
left a comment
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.
LGTM, just have one non blocking thought/question about the API.
| legendAllowWrap?: boolean; | ||
| /** | ||
| * @beta If legendAllowWrap is true, this function will be called after the legend's itemsPerRow property has been | ||
| * calculated, based on available width. The value provided can be used to increase the chart's parent container | ||
| * height as legend items wrap onto the next line. If no adjustment is necessary, the value will be zero. | ||
| */ | ||
| legendAllowWrapCallback?: (extraHeight: number) => void; |
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.
What would you think about updating the type for legendAllowWrap to be something like boolean | (extraHeight: number) => void; rather than adding a new prop explicitly for the CB that doesn't apply unless legendAllowWrap is true?
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.
@wise-king-sullyman I merged legendAllowWrap and legendAllowWrapCallback.
3879b7d to
99e927f
Compare
99e927f to
de08b23
Compare
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
Added an optional callback to compliment the chart's
legendAllowWrapproperty. ThelegendAllowWrapCallbackprop will be used to adjust the chart's parent containerheightas legend items wrap in response to the availablewidth.Example:

Closes #8643