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

[BUG] - Table: specifying both emptyContent and loadingContent shows both of them while content is loading #2470

Closed
brunokc opened this issue Mar 8, 2024 · 11 comments · Fixed by #2491
Labels
🐛 Type: Bug Something isn't working

Comments

@brunokc
Copy link
Contributor

brunokc commented Mar 8, 2024

NextUI Version

2.2.9

Describe the bug

If I'm loading data dynamically, and use both loadingContent and emptyContent, NextUI seems to show both of them while isLoading is true and then either keep emptyContent if I get nothing back, or both of them disappear if the API returns actual content.

image

Tangential to this, you'll also notice that when there's no emptyContent defined and items is empty ([]), the loading element will be rendered on top of the columns. I think it's missing a minimum height in its definition.

Your Example Website or App

https://stackblitz.com/edit/nextui-table-bug

Steps to Reproduce the Bug or Issue

  1. Use Table
  2. Ensure isLoading is true
  3. Ensure emptyContent is non-empty
  4. Ensure items is an empty array ([])

Expected behavior

loadingContent and emptyContent should be mutually exclusive. While loadingContent is being rendered, emptyContent should not be used, and vice-versa.

Screenshots or Videos

No response

Operating System Version

Windows

Browser

Edge

@brunokc brunokc added the 🐛 Type: Bug Something isn't working label Mar 8, 2024
brunokc added a commit to brunokc/nextui that referenced this issue Mar 8, 2024
Avoid displaying loadingContent and emptyContent at the same time.
@alphaxek
Copy link
Contributor

alphaxek commented Mar 8, 2024

Hi @brunokc, Please try this client side logic.

emptyContent={
 !state.isLoading ? 'No data. Click "Add" to add a new row.' : ' '
}

table

If this helps please mark this discussion #2427 as answered, will really appreciate, thanks!

@brunokc
Copy link
Contributor Author

brunokc commented Mar 8, 2024

Thank you @alphaxek. Yes, that helps, and I already used something like that. I would expect the framework to take care of that for me though.

@alphaxek
Copy link
Contributor

alphaxek commented Mar 8, 2024

Hi @jrgarciadev @tianenpang @wingkwong,

Is this issue supposed to be handled on client side or by framework itself?

@wingkwong
Copy link
Member

IMO empty content and loader shouldn't be shown at the same time. @brunokc I've seen you changed something already. Can you make a PR?

@alphaxek
Copy link
Contributor

alphaxek commented Mar 9, 2024

@wingkwong yes correct both shouldn't be shown, but is it a client side issue or framework issue?

@wingkwong
Copy link
Member

I think it should be handled by the framework. Users shouldn't add such logic themselves.

@alphaxek
Copy link
Contributor

alphaxek commented Mar 9, 2024

okay thanks for clearing, I think @brunokc already got a solution to it in nextui/packages/components/table/src/table-body.tsx, @brunokc can raise PR.

@brunokc
Copy link
Contributor Author

brunokc commented Mar 9, 2024

Awesome, I'll work on that PR shortly. Thanks, everyone!

@alphaxek
Copy link
Contributor

alphaxek commented Mar 9, 2024

@brunokc If your query is resolved please mark as answered, will appreciate, thanks!

brunokc added a commit to brunokc/nextui that referenced this issue Mar 10, 2024
Avoid displaying loadingContent and emptyContent at the same time.
Note that there's an existing issue with loadingContent where if
emptyContent is not provided, it will render loadingContent on top of
the columns (instead of inside the table). This change doesn't fix that,
but rather make isLoading play nice with a provided emptyContent. A
separate fix is still needed for when emptyContent is not provided, which
may affect this change later.
@brunokc
Copy link
Contributor Author

brunokc commented Mar 10, 2024

Sorry for the delay. I ran into the other issue I mentioned where loadingContent is rendering wrong in the absence of emptyContent. I decided to change my fix to get things going, but I'll start a discussion in the PR to see how you guys think we should proceed.

jrgarciadev pushed a commit that referenced this issue Mar 10, 2024
Avoid displaying loadingContent and emptyContent at the same time.
Note that there's an existing issue with loadingContent where if
emptyContent is not provided, it will render loadingContent on top of
the columns (instead of inside the table). This change doesn't fix that,
but rather make isLoading play nice with a provided emptyContent. A
separate fix is still needed for when emptyContent is not provided, which
may affect this change later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants