Skip to content

renderDetailPanel shows a detail panel when the rows array is empty #525

Open

Description

@FenderStrat85

mantine-react-table version

2.0.0-beta.9

react & react-dom versions

react-dom: 18.3.1, react: 18.3.1

Describe the bug and the steps to reproduce it

If there are no rows passed into the table the expand row button is shown and the component rendered using the renderDetailPanel will still be shown if the expand row button is clicked

Additionally when setting test-ids for each row as per below:
mantineTableBodyRowProps: { "data-testid": "a-test-id" },

In previous versions, if there were no rows, and the "No records to display" text was shown, checking for this testid would show that there are no rows. In version 2.0.0-beta.9, it shows there are 2 rows, 1 containing the "No records to display" text and the other being the detail panel

Minimal, Reproducible Example - (Optional, but Recommended)

https://codesandbox.io/p/sandbox/9gkh5g - apologies the styles are hideous but this should show what the problem is.

Screenshots or Videos (Optional)

Screen.Recording.2025-06-09.at.15.09.21.mov

Do you intend to try to help solve this bug with your own PR?

No, because I do not have time to dig into it

Terms

  • I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Activity

  1. masterbater commented on Jun 17, 2025

    @masterbater

    Just add this condition

    if (
    				!row.original || // covers null and undefined
    				(typeof row.original === "object" &&
    					Object.keys(row.original).length === 0)
    			) {
    				return;
    			}

    They have note that renderDetailPanel will also render for empty row

    //Now that empty row is an actual row, detail pannel is available for empty row as well

  2. FenderStrat85 commented on Jun 17, 2025

    @FenderStrat85
    Author

    Just add this condition

    if (
    !row.original || // covers null and undefined
    (typeof row.original === "object" &&
    Object.keys(row.original).length === 0)
    ) {
    return;
    }
    They have note that renderDetailPanel will also render for empty row

    mantine-react-table/packages/mantine-react-table/stories/features/EmptyRow.stories.tsx

    Line 95 in 07ee2ef

    //Now that empty row is an actual row, detail pannel is available for empty row as well

    Nice one, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions