question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rendering `Collapse` within `HTMLTable` doesn't seem to work, what am I doing wrong?

See original GitHub issue

Environment

  • Package version(s): 3.17.1
  • Browser and OS versions: Electron 3.0.7

Question

I don’t really get the behavior that I expect from the interaction between Collapse and HTMLTable. Basically, I have a list of table rows that need to expand into larger groups, e.g.:

foo v
    sub foo 1
    sub foo 2
    sub foo 3
bar ^
baz ^

Clicking foo should expand or collapse the subcategories as necessary. Pretty straightforward.

The problem is that neither of the things I expect to work actually work when the Collapse contents are generated from props. I tried two things:

render() {
        return (
            <React.Fragment>
                <tr>
                    ...
                </tr>

                {redacted.map((...) =>
                    <Collapse isOpen={this.state.isOpen} component="tr" keepChildrenMounted={true}>
                        ...
                    </Collapse>
                )}
            </React.Fragment>
        )
    }

which renders a ton of collapses as trs, as well as having Collapse outside of the map call, which creates one single Collapse with a bunch of programmatically generated trs.

Both of these fail for the same reason, because the contents of Collapse are still a div:

<tr class="bp3-collapse">
    <div class="bp3-collapse-body" aria-hidden="true" style="transform: translateY(0px);">   
        <td>blah</td>
         ... a bunch more td tags
    </div>
</tr>

which just throws:

Warning: validateDOMNesting(...): <div> cannot appear as a child of <tr>.
    in div
    in tr
    in Blueprint3.Collapse (created by Redacted)

So, uh, what am I doing wrong? The documentation says that component is used for rendering collapses inside tables, so I know this is POSSIBLE. :p Thanks in advance.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
justinbhoppercommented, Mar 17, 2022

@adidahiya I think at this point this should just be considered a documentation bug.

The docs say “Useful when rendering a Collapse inside a <table>, for instance.”, but really it should say “Useful when rendering a Collapse inside a <td>, for instance.”

Because there’s no way the current implementation could render valid HTML if setting component="tr" or component="table", since a div will always be rendered wrapping the children.

1reaction
adidahiyacommented, Jan 22, 2020

If anyone is still encountering this issue, can you please use the issue template and provide a code sandbox we can poke at to debug? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong html table rendering using colspan and rowspan
I have included fixed height style in your code. Observe the difference. table { border: 2px solid; border-collapse: collapse; } td ...
Read more >
Table Troubleshooting (Web Design in a Nutshell, 2nd Edition)
As of this writing, all versions of Netscape (even 6) collapse empty cells and do not render a background color in a collapsed...
Read more >
HTML table advanced features and accessibility
You can give your table a caption by putting it inside a <caption> element and nesting that inside the <table> element. You should...
Read more >
HTML Tables: All there is to know about them - freeCodeCamp
Border works on any of the table elements and just about how you would expect. The quirks come in when you collapse the...
Read more >
10 Most Common Bootstrap Mistakes That Developers Make
To make it plain and simple: Do not modify the bootstrap.css file. ... Create your new CSS selector, use it in the HTML,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found