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.

Building table rows with child components breaks table striping

See original GitHub issue

Using a parent table component and creating table rows out of child components results in alternating table_row and script tags like so:

<tr unicorn:id="3gyuTizE:payment-row:56" unicorn:name="payment-row" unicorn:key="56" unicorn:checksum="GnYyQM78">
...
</tr>
<script type="module">if (typeof Unicorn === 'undefined') { console.error('Unicorn is missing. Do you need {% load unicorn %} or {% unicorn-scripts %}?') } else { Unicorn.componentInit({"id":"3gyuTizE:payment-row:56",...}</script>

This breaks table striping as implemented in many css frameworks (tested with Bulma, Materialize, Picnic and Siimple). Using plain css as below also does not work properly b/c of the additional script tags after every row:

tr:nth-child(even) {
    background-color: #F3F4F6;
}
tr:nth-child(odd) {
    background-color: #aeb2bb;
} 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cleonellocommented, Jan 28, 2021

Thanks! Just updated and seems to work as expected!

1reaction
cleonellocommented, Jan 26, 2021

Awesome! Yes, it would solve the issue. I also agree that it would be cleaner not to output a script tag for each child component.

BTW, great work on django-unicorn! I’m excited to try it out on a couple new projects. Thanks for the hard work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular child component breaks table - Stack Overflow
This is a side effect of tables being rigid in structure. You can get around this by using the component as an attribute...
Read more >
Zebra Striping Tables With CSS3 - Opera
Zebra striping—or, coloring or shading alternate rows on a table—is thought to enhance the usability of a table by guiding the user's eye ......
Read more >
Building a Data Table Component in React — Development
Here's how to create a stripped down version of the data table we built for Polaris using React (note: This post requires polaris-react....
Read more >
Creating Zebra-Striped Tables - the new code
This is an entirely appropriate use of a table: the concert dates are truly tabular data, with relevant, related information in each row....
Read more >
Accessible, Simple, Responsive Tables | CSS-Tricks
Will break any unique IDs inside a table. Poor idea for Styleguide driven components. Using normal table markup and JavaScript at a breakpoint ......
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