Skip to content

Conversation

@dlabrecq
Copy link
Member

@dlabrecq dlabrecq commented Feb 17, 2023

Added an optional callback to compliment the chart's legendAllowWrap property. The legendAllowWrapCallback prop will be used to adjust the chart's parent container height as legend items wrap in response to the available width.

Example:
chrome-capture-2023-1-16

Closes #8643

@patternfly-build
Copy link
Contributor

patternfly-build commented Feb 17, 2023

@dlabrecq dlabrecq force-pushed the v5-8643-legendAllowWrapCallback branch 2 times, most recently from e4bd433 to 97090c7 Compare February 17, 2023 05:04
@dlabrecq dlabrecq changed the title Charts - Add legendAllowWrap callback Charts - add legendAllowWrap callback Feb 17, 2023
@dlabrecq dlabrecq added the PF5 label Feb 17, 2023
@dlabrecq dlabrecq force-pushed the v5-8643-legendAllowWrapCallback branch from 97090c7 to ed16f7f Compare February 20, 2023 14:15
Copy link
Contributor

@nicolethoen nicolethoen left a 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.

@dlabrecq
Copy link
Member Author

dlabrecq commented Feb 21, 2023

@nicolethoen I've fixed the lint warnings.

@dlabrecq dlabrecq requested a review from nicolethoen February 22, 2023 19:59
Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a 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.

Comment on lines 250 to 256
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;
Copy link
Contributor

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?

Copy link
Member Author

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.

@dlabrecq dlabrecq force-pushed the v5-8643-legendAllowWrapCallback branch from 3879b7d to 99e927f Compare February 28, 2023 01:44
@dlabrecq dlabrecq force-pushed the v5-8643-legendAllowWrapCallback branch from 99e927f to de08b23 Compare February 28, 2023 01:55
@nicolethoen nicolethoen merged commit 7661b9f into patternfly:v5 Mar 1, 2023
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-charts@7.0.0-alpha.9
  • @patternfly/react-docs@6.0.0-alpha.22

Thanks for your contribution! 🎉

@dlabrecq dlabrecq deleted the v5-8643-legendAllowWrapCallback branch March 24, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Charts - legendAllowWrap callback

5 participants