nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Table sub components "as" prop does not work

Open jprosevear opened this issue 8 months ago • 5 comments

HeroUI Version

latest

Describe the bug

Using "as" prop on TableHeader, TableColumn, TableBody, TableRow,

It does have effect on Table

Your Example Website or App

https://codesandbox.io/p/devbox/dreamy-villani-kj37k4?file=%2FApp.jsx%3A16%2C24

Steps to Reproduce the Bug or Issue

See CodeSandbox

Expected behavior

as property takes effect

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

jprosevear avatar Apr 19 '25 17:04 jprosevear

I think as here shouldn't take effect as they should be just HTMLTableElement. May I know your use case that you need to use div?

wingkwong avatar Apr 20 '25 07:04 wingkwong

The div is just a sample - I'm trying to use a <Link> from Tanstack Router - if I pass an href the code will use an 'a' but that doesn't work, see https://github.com/adobe/react-spectrum/pull/7695.

jprosevear avatar Apr 22 '25 11:04 jprosevear

This is also a problem for me, I want to use <TableRow as={motion.tr} />, but it doesn't have any effect(

drebot92 avatar May 19 '25 15:05 drebot92

This is also a problem for me, I want to use <TableRow as={motion.tr} />, but it doesn't have any effect(

Same! I have to jump through a few hoops to animate a table because of this. If I could do <TableRow as={motion.tr} />, it would make my life much easier! Now I have to animate each cell individually (see below), which is less performant and creates undesirable side-effects.

Cannot do now:

<TableRow as={motion.tr} layout layoutId={itemLayoutId}>
    <TableCell>
        ...
    </TableCell>
</TableRow>

Instead, I need to do:

<TableRow>
    {(columnKey) => (
        <TableCell>
            <motion.div layout layoutId={itemLayoutId + columnKey}>
                ...
            </motion.div>
        </TableCell>
    )}
</TableRow>

alextouzel avatar Jun 12 '25 07:06 alextouzel