Skip to content
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(Toolbar): deleteChip expects categoryKey as string #4553

Merged
merged 2 commits into from
Jul 29, 2020

Conversation

nicolethoen
Copy link
Contributor

Closes #3552

@@ -67,21 +67,23 @@ export class ToolbarFilter extends React.Component<ToolbarFilterProps, ToolbarFi
render() {
const { children, chips, deleteChipGroup, deleteChip, categoryName, showToolbarItem, ...props } = this.props;
const { isExpanded, chipGroupContentRef } = this.context;
const categoryKey = typeof categoryName === 'string' ? categoryName : categoryName.key;
Copy link
Member

@dlabrecq dlabrecq Jul 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking we should test typeof ToolbarChipGroup before returning categoryName.key? (It's possible that key may not be defined for the given object.) That way, the string could be returned as the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only types valid for categoryName is string or ToolbarChipGroup which requires a key. So it should be safe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although categoryName is typed, users can still provide a different object (e.g., categoryName={myObject as any}). I'm just advocating that it's safer to test for the ToolbarChipGroup interface first (since you're already using typeof) and default to string; thus, avoiding a potential undefined exception.

@patternfly-build
Copy link
Contributor

patternfly-build commented Jul 15, 2020

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlabaj tlabaj merged commit f49358c into patternfly:master Jul 29, 2020
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@4.6.3
  • @patternfly/react-core@4.35.0
  • @patternfly/react-docs@5.6.25
  • @patternfly/react-inline-edit-extension@4.5.50
  • demo-app-ts@4.25.3
  • @patternfly/react-table@4.13.17
  • @patternfly/react-topology@4.4.52
  • @patternfly/react-virtualized-extension@4.5.40

Thanks for your contribution! 🎉

@nicolethoen nicolethoen deleted the deleteChip_params_change branch February 8, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataToolbarFilter: categoryName label required to delete chips
5 participants