Skip to content

[BUGFIX] Table render no data if no record exists#487

Merged
shahrokni merged 1 commit intoperses:mainfrom
shahrokni:fix/table_show_no_data_accordinly
Nov 25, 2025
Merged

[BUGFIX] Table render no data if no record exists#487
shahrokni merged 1 commit intoperses:mainfrom
shahrokni:fix/table_show_no_data_accordinly

Conversation

@shahrokni
Copy link
Copy Markdown
Contributor

@shahrokni shahrokni commented Nov 25, 2025

Closes perses/perses#3564

Description 🖊️

If no data exists, the table contains a No data message.

🧪 To test this you can use a query which returns no results.

image

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

@AntoineThebaud AntoineThebaud added this pull request to the merge queue Nov 25, 2025

return (
<div>
return data?.length ? (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest making an early return statement here instead of using the ternary operator spanning more than 100 lines. In my opinion it makes it easier to reason about the control flow:

if (!data || data.length === 0) {
  return <Box
    sx={{
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      height: '100%',
    }}
  >
    <Typography>No data</Typography>
  </Box>;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep, I agree

@Gladorme Gladorme removed this pull request from the merge queue due to a manual request Nov 25, 2025
Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com>

Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com>
@shahrokni shahrokni force-pushed the fix/table_show_no_data_accordinly branch from 7f9d929 to 2e95ac3 Compare November 25, 2025 13:24
}

return (
<div>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure we can safely remove this div?
And why there is html here and no MUI 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The root (parent) for every component

We can safely remove the div because it contains no specific style and it will be rendered like a loose container which can hold stuff. The only reason the developer used it was probably the fact you can not have parallel children with no parents.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@shahrokni I thought the same before, until I had the following case:

export default function ParentComponent() {
  return (
    <div style={{display:"flex", width: 500, justifyContent:"space-between"}}>
      <div>box1</div>
      <MyComponent />
      <div>box4</div>
    </div>
  );
}

function MyComponent() {
  return (
    <div>
      <div>box2</div>
      <div>box3</div>
    </div>
  );
}

Now, remove the outer <div> of the MyComponent, and you'll see that removing it does have an effect. So we can't remove the parent div element in all cases, even if it might look unstyled.

@shahrokni shahrokni added this pull request to the merge queue Nov 25, 2025
Merged via the queue into perses:main with commit 5cb5f0e Nov 25, 2025
13 checks passed
@shahrokni shahrokni deleted the fix/table_show_no_data_accordinly branch November 25, 2025 13:46
abelyakin pushed a commit to abelyakin/plugins that referenced this pull request Jan 14, 2026
Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com>
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.

Table: empty query results should show "No data"

4 participants