mavo icon indicating copy to clipboard operation
mavo copied to clipboard

More weirdness with mv-list on tables

Open karger opened this issue 2 years ago • 5 comments

Rendering on a table materializes a gratuitious rendering of the data as javascript. https://codepen.io/karger/pen/xxMzxOp?editors=1100

karger avatar Nov 24 '23 06:11 karger

I think the table is mostly a red herring here, the issue is a well known old one, where there is nothing in there to tell Mavo that this is a group, so it renders it as a primitive.

LeaVerou avatar Nov 24 '23 08:11 LeaVerou

But note that with the div just above, the extra content is not rendered. Only in the table. Try editing the data at the top.

karger avatar Nov 24 '23 14:11 karger

But note that with the div just above, the extra content is not rendered. Only in the table. Try editing the data at the top.

Yes, because with the <div>, the list item has no children (except text nodes), and the <tr> has two of them. You'll start observing the same result if you re-create a similar structure (e.g., by wrapping expressions—[name] and [age]—into <span>s).

As Lea mentioned, adding mv-group to the list items solves the issue.

DmitrySharabin avatar Nov 24 '23 14:11 DmitrySharabin

I don't understand the rule that is being followed---why does the presence of children affect what happens?

karger avatar Nov 24 '23 15:11 karger

I don't understand the rule that is being followed---why does the presence of children affect what happens?

In the first case (no children), Mavo replaces the element text content (as it holds the property value). In the second case, it inserts a new text node before the children (to preserve the authored HTML).

SCR-20231124-ojia
SCR-20231124-ojmv

DmitrySharabin avatar Nov 24 '23 15:11 DmitrySharabin