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

Fixed bug in EuiBasicTable to handle dynamic icon value properly in collapsed actions #3145

Merged
merged 5 commits into from
Mar 31, 2020

Conversation

crux153
Copy link
Contributor

@crux153 crux153 commented Mar 22, 2020

Summary

Fix for #3144

While DefaultItemAction accepts a function to dynamically change icon value as like below,

type IconFunction<T> = (item: T) => EuiIconType;
export interface DefaultItemIconButtonAction<T>
  extends DefaultItemActionBase<T> {
  type: 'icon';
  icon: EuiIconType | IconFunction<T>;
  color?: EuiButtonIconColor | EuiButtonIconColorFunction<T>;
}

It crashes when shown in CollapsedItemActions component, since the logic to handle functional icon prop is present only in DefaultItemAction and missing in CollapsedItemActions.

{
    name: 'Clone',
    description: 'Clone this user',
    icon: item => (item.online ? 'eye' : 'eyeClosed'),
    onClick: this.cloneUser,
    'data-test-subj': 'action-clone',
}

Screen Shot 2020-03-22 at 4 43 49 PM

If I pass an action with dynamic icon value like above, the table crashes when clicking the expand button in action column.

This PR adds the missing handler to CollapsedItemActions so that it works in the same way as DefaultItemAction does.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cchaos
Copy link
Contributor

cchaos commented Mar 24, 2020

@crux153 Can you please give more explanation in the summary?

@crux153
Copy link
Contributor Author

crux153 commented Mar 25, 2020

@cchaos I updated the summary. Thanks!

@chandlerprall chandlerprall self-requested a review March 25, 2020 21:02
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for digging into this and finding the root cause. I've asked for two small changes, otherwise this looks great.

src/components/basic_table/collapsed_item_actions.tsx Outdated Show resolved Hide resolved
src/components/basic_table/collapsed_item_actions.tsx Outdated Show resolved Hide resolved
@crux153
Copy link
Contributor Author

crux153 commented Mar 27, 2020

@chandlerprall I just copied the implementation detail from existing DefaultItemAction component. I love your setup as it is much cleaner than before, so I applied the same changes to both components. Thank you :)

@cchaos cchaos requested a review from chandlerprall March 30, 2020 19:27
@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3145/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Thanks for tracking down the root cause, and the extra cleanup on this one!

@chandlerprall chandlerprall merged commit d187ea4 into elastic:master Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants