Possibility of switching core/table from static to dynamic block? #55089
Replies: 2 comments 4 replies
-
Hi, @Sidsector9, The core table block supports colSpan and rowSpan attributes. Therefore, if the logic that merge/un-merge cells properly controls those attributes, the block should not be broken. Additionally, I think you should only create dynamic blocks where the content changes due to external factors, such as a site title block, or when the content changes when the block is rendered, such as a recent posts block. I think another reason not to make blocks dynamic is to avoid reducing performance during rendering. By the way, I have created a custom table block in the past to try the cell merging/unmerging function. This plugin is also published in the plugin directory. |
Beta Was this translation helpful? Give feedback.
-
The demo in the video looks really cool! The problem you mention is a really interesting one. It'd be really useful to have a PR to reference showing the issue so we can discuss potential solutions, as it's hard to visualize what's happening without being able to debug it. |
Beta Was this translation helpful? Give feedback.
-
What problem does this address?
Hello all, I wanted to discuss the possibility of converting/migrating the core Table block from static to dynamic type, and I am not sure whether this is possible, or at least discouraged.
There is a list of feature requests & enhancements for the Table block here - #32400
Recently, I picked up the feature request to merge/un-merge cells here - #15821
and made decent progress:
Screen.Recording.2023-09-12.at.1.45.54.AM.mov
This works pretty well until you save and reload. If you try to merge cells after reloading, it will break.
The reason is, when the HTML is saved to the DB, it excluded the cells that were part of the merged cell. Due to this, when the editor reconstructs the table using the
save
function, the original index values are lost.I found it to be extremely complicated to fix it as the context of the table before and after saving is lost. And reconstruction passes values to the attributes after parsing the HTML of the saved data.
If we were to use a dynamic table, we could store this information as Block attributes and then use it to build the table server-side.
What is your proposed solution?
I have more of a concept at the moment rather than the actual solution. If this is feasible then I'll be more than willing to contribute to the discussion.
Beta Was this translation helpful? Give feedback.
All reactions