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: #455 Use proper detailPanel callback signature when detailPanel is an array of callbacks #468

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

tondi
Copy link
Contributor

@tondi tondi commented Jan 27, 2022

Related Issue

#455

Description

Fixes wrong type. The proper type when using callback in multiple detail panel is (rowData: RowData) => ... instead of ({rowData} => {rowData: RowData}) as types suggest.

This problem can be seen when we modify the example of multiple detail panels to:

[(rowData) => {
  console.log(rowData);

  return ({
    icon: 'favorite_border',
    openIcon: 'favorite',
    tooltip: 'Show Both',
    render: ({ rowData }) => {
      return (
        <div
          style={{
            fontSize: 102,
            textAlign: 'center',
            color: 'white',
            backgroundColor: '#FDD835'
          }}
        >
          {rowData.name} {rowData.surname}
        </div>
      );
    }
  });
}]

Then the result of console.log is

{name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34, id: 3, …}

not

{
   rowData: {
      name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34, id: 3, …
   }
}

This is probably a rare case when someone needs rowData outside of detailPanel render(), but then all they can do is to suppress type error.
It may also be that we want ({rowData: RowData}) => .. to be passed here as is it is with render(). If so I propose setting up another PR for that

…e when detailPanel is an array of callbacks
@tondi tondi requested a review from oze4 as a code owner January 27, 2022 15:41
@Domino987 Domino987 merged commit b6ae7bc into material-table-core:master Jan 27, 2022
@Domino987
Copy link
Contributor

Thank you for the contribution!

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.

None yet

2 participants