fix(EuiBasicTable): fixed EuiBasicTable proptypes of itemId#3133
fix(EuiBasicTable): fixed EuiBasicTable proptypes of itemId#3133chandlerprall merged 5 commits intoelastic:masterfrom
Conversation
|
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? |
|
Jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3133/ |
|
@pranshuchittora Can you describe how you found the issue to be that |
chandlerprall
left a comment
There was a problem hiding this comment.
The root case here is the re-use of ItemId<T> type for both EuiBasicTable's itemId and CollapsedItemActions's itemId. This was an oversight during these components' translation to TypeScript.
EuiBasicTable uses its itemId to know what field on an object is its ID, thus the string | ((item: T) => string) definition. However, CollapsedItemActions's itemId is the resolved value (either a string or a number are valid, thus the change).
The proper way to fix this is to re-define CollapsedItemAction's itemId as string | number, not ItemId<T>. expanded_item_actions.tsx should be updated similarly.
|
Why the |
|
It needs the generic type because, when it is a function, it is passed the item as its argument. For the tables, the item type is represented by the generic. The code using |
chandlerprall
left a comment
There was a problem hiding this comment.
Looks good, but needs to make the same changes to src/components/basic_table/expanded_item_actions.tsx
chore(CHANGELOG): updated the changelog docs(EuiBasicTable): updated propTypes
|
@chandlerprall please review the new changes :) |
chandlerprall
left a comment
There was a problem hiding this comment.
Changes LGTM; Pulled & tested locally. I also merged in master to correct the changelog entry placement (releases often screw up open PR changelogs)
|
Thanks for the bugfix @pranshuchittora ! |
Summary
Closes #3130
Summarize your PR. If it includes design elements include a screenshot or gif.
As of now, I have added a type the propTypes of ItemId (
number).Another approach is that I can convert the given input to String.
Checklist