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

Hiding the table make the empty text no longer centered #421

Open
1 task done
iscy opened this issue Oct 16, 2024 · 0 comments
Open
1 task done

Hiding the table make the empty text no longer centered #421

iscy opened this issue Oct 16, 2024 · 0 comments

Comments

@iscy
Copy link

iscy commented Oct 16, 2024

mantine-react-table version

v2.0.0.beta7

react & react-dom versions

v18.2.0

Describe the bug and the steps to reproduce it

  1. Display a table with 0 rows
  2. Hide the table (use the Mantine tabs without disabling keepMounted)
  3. Show the table
    => The text "No records to display" will no longer be centered

Minimal, Reproducible Example - (Optional, but Recommended)

The problem is related to these lines:

                  <Text
                    __vars={{
                      '--mrt-paper-width': `${tablePaperRef.current?.clientWidth}`,
                    }}
                    className={clsx(classes['empty-row-td-content'])}
                  >

Once hidden, clientWidth becomes 0. Once we re-display the table again, clientWidth will be 0 on the first redraw but then be properly set on the next one. We can work around the issue by forcing a redraw, however, by removing the var 'mrt-paper-width', the text will occupy 100% of its space and the issue will be fixed. I can open a PR with the removal of this line, but it was introduced in the PR allowing virtualization and might be needed for a certain use case. Feel free to point me in the right direction for the PR.

Screenshots or Videos (Optional)

mrt

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

Yes, I think I know how to fix it and will discuss it in the comments of this issue

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.
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

No branches or pull requests

1 participant