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

Using <div /> elements for TableBody component produces TypeScript errors #644

Open
2Pacalypse- opened this issue Apr 24, 2022 · 5 comments
Labels
enhancement New feature or request hacktoberfest This issue is suitable for the hacktoberfest ;) PR welcome You can give that a try :)

Comments

@2Pacalypse-
Copy link

Describe the bug
When using a custom TableBody component, we need to forward a ref to it. However, react-virtuoso types expect this ref to point to a tbody element, so when I try to use a div element instead, I get a TypeScript error.

Reproduction

<TableVirtuoso
  components={{
    TableBody: React.forwardRef((props, ref: React.ForwardedRef<HTMLDivElement>) => (
      <div ref={ref} {...props} />
    )),
  }}
/>

Expected behavior
It would be nice if we could use the non-tbody elements for TableBody component without resorting to using as any.

@2Pacalypse- 2Pacalypse- added the bug Something isn't working label Apr 24, 2022
@petyosi petyosi added enhancement New feature or request PR welcome You can give that a try :) and removed bug Something isn't working labels Apr 24, 2022
@petyosi petyosi changed the title [BUG] Using <div /> elements for TableBody component produces TypeScript errors Using <div /> elements for TableBody component produces TypeScript errors Apr 24, 2022
@petyosi
Copy link
Owner

petyosi commented Apr 24, 2022

I'm still unsure why you do tables with divs, but to each their own. Feel free to submit a PR over the matter.

@tigranpetrossian
Copy link

Hi @petyosi, browser's native behavior for tables can sometimes get in the way when it comes to making native-like data tables: sometimes entire rows can have context menus, or be link/other clickable context for sighted users, while maintaining table semantics for screen readers. There's also random quirks (as it's always the case with the web) like sticky headers behaving weirdly in Chrome when borders are collapsed, etc.

I think this is a valid issue, the TypeScript bits can be technically silenced by assertion in the userland, but the library also injects a tr -> td filler that triggers validateDomNesting errors from react-dom. I'll look into sending a PR once I figure out how the latter works.

@petyosi
Copy link
Owner

petyosi commented Oct 17, 2022

@tigranpetrossian the filler is also exposed as a custom component. https://virtuoso.dev/api/interfaces/_interfaces_.tablecomponents#fillerrow

@tigranpetrossian
Copy link

Thanks @petyosi ❤️ Found that out after digging deeper.

@petyosi petyosi added the hacktoberfest This issue is suitable for the hacktoberfest ;) label Sep 7, 2023
@ArturKustyaev
Copy link

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest This issue is suitable for the hacktoberfest ;) PR welcome You can give that a try :)
Projects
None yet
Development

No branches or pull requests

4 participants