# Table Builder Component broken?

**URL:** https://meta.discourse.org/t/table-builder-component-broken/262491
**Category:** Bug
**Tags:** table-builder
**Created:** [April 21, 2023, 9:03am UTC](https://meta.discourse.org/t/table-builder-component-broken/262491 "2023-04-21T09:03:22Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Ralf\_Stockmann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ralf_stockmann/32/505867_2.png) [@Ralf\_Stockmann](https://meta.discourse.org/u/Ralf_Stockmann)
#### Post date: [April 21, 2023, 9:03am UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/1 "2023-04-21T09:03:22Z")

</div>

The new and awesome Table Builder Component seems to have a problem (Version 0.0.1): after creating a table (works like a charm), no data is loaded into the table editor if I use the “edit” icon. _Sometimes_ however, it works - maybe 1 out of 10 tries, so maybe there is some timeout/race condition foo going on…

I can reproduce it on 2 different servers, Discourse 3.1.0.beta3 (one of them near-vanilla with no additional plugins/components)

Any thoughts?

Test:

| Column 1 | Column 2 | Column 3 | Column 4 | E |
| --- | --- | --- | --- | --- |
| Test 1 | Test 2 | Test 4 | Test 4 | |
| Tesing again | more | | | |

---

<div class="post-metadata">

### Author: ![Ralf\_Stockmann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ralf_stockmann/32/505867_2.png) [@Ralf\_Stockmann](https://meta.discourse.org/u/Ralf_Stockmann)
#### Post date: [April 21, 2023, 9:04am UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/3 "2023-04-21T09:04:46Z")

</div>

And it’s happening on this server, too - this is the table above via edit:

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/0/6/f060135713adde617146ed084001a5a35c70e992.png)

Browser: Google Chrome 112 / Safari 16.5

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 21, 2023, 9:05am UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/4 "2023-04-21T09:05:02Z")

</div>

I think I can repro this. When I first tried to edit the table above it was blank, but on subsequent tries it seems to include the info.

And now blank again on another try (with the option to ‘build table’ rather than ‘save’).

(Windows 11/Firefox)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [April 21, 2023, 2:23pm UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/6 "2023-04-21T14:23:06Z")

</div>

I can reproduce this as well here. I noticed it days ago when I posted a theme component and forgot to report 😄  
Not quite the same context, though.

I could see the data after the 4th try:

Windows 10 with Chrome.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [April 25, 2023, 1:40pm UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/11 "2023-04-25T13:40:06Z")

</div>

Thanks for the reports, folks. The issue here was that if the click was on the svg icon directly, the ID of the table wasn’t being passed correctly to the editor (if the click target was near the icon, then the event target was correct).

It should be fixed once this PR is reviewed/merged: [FIX: Table editing sometimes not working by pmusaraj · Pull Request #50 · discourse/discourse-table-builder · GitHub](https://github.com/discourse/discourse-table-builder/pull/50)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 25, 2023, 3:08pm UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/13 "2023-04-25T15:08:03Z")

</div>

This has been merged now. 👍

> <https://github.com/discourse/discourse-table-builder/pull/50>
>
> We were relying on the \`event.target\`, and sometimes that target was not the but…ton element with the \`table-id\` data attribute, but the svg. 
> 
> This PR makes a few changes: 
> 
> \- renames \`tableId\` to \`tableIndex\`
> \- passes the index as part of the attributes to the \`generateModal\` function

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 29, 2023, 7:00am UTC](https://meta.discourse.org/t/table-builder-component-broken/262491/14 "2023-04-29T07:00:03Z")

</div>

This topic was automatically closed after 3 days. New replies are no longer allowed.
