athens
athens copied to clipboard
Embedding block on same page freezes Athens
Problem
When embedding a block in itself it freezes Athens.
Ideally, it either gives a warning that this is not possible or it can handle self-embeds. Admittedly, this is likely an unusual scenario, but it happened when I experimented with it.
Athens Version Beta 76
Can reproduce^^
This seems to be a rendering problem: I believe Athens tries to render the total tree down to its leaves, but it's not a tree but a circular graph!
I see some possible ways to fix this:
- collapse blocks in an embed environment per default. This requires some design changes in the behavior of blocks inside an embedded block. Currently, children of an embedded block, rendered in the embedding, are expanded if and only if the original child block, rendered outside the embedding, is expanded (spooky action at a distance, might be bug or feature...). See this Loom demo -- I hope I explained it well.
- We could also choose that the page view only renders the tree up to a depth of 20.
- Still another option: Cycle detection and children that are their own ancestors in the rendered tree don't render their children.
However, a block has two (grand-)children referencing to itself, option 2 would still get pretty exponential. I don't like the user experience of option 3, so I would favor option 1.
@datokrat It seems it has nothing to do with the fact that the current block is on the same page. I can embed blocks from the same page.
The issue appears when you try to embed a block that is an ancestor of the current block. Athens will then end up in an endless loop which causes the freeze, because the embedded block contains an embedded block to itself.