- Issue created by @swirt
- πΊπΈUnited States swirt Florida
Given the nature of Mermaid and how the order does not change the diagram, this may not be fixable. Will need more investigation.
- πΊπΈUnited States beeyayjay
Elements are added using a breadth-first search, first for referenced entities and then for referencing entities. So the order is:
- Starting element
- All children of starting element (elements referenced in starting element)
- All children of first child, all children of second child, etc. to selected depth
- All parents of starting element (elements that reference the starting element)
- All parents of first parent, all parents of second parent, etc. to selected depth
Mermaid uses that order, but uses it's own logic to place elements on the screen, apparently with the intention of minimizing crossed connecting lines. It appears that when only one level is shown (direct children or direct parents), the focus starts with the left-most element on the screen and continues to the right as expected, but with more levels and more complex interconnections, Mermaid rearranges the elements, so focus often jumps around.
This means we can affect some aspects of the focus order by changing the way related elements are added. We could put parent elements (which appear above the starting element) first. We could also use a depth-first search, so, after the first child of the starting element, the focus would move to the first child of that child, and so on until the depth is reached or there are no more children.
I don't know if either of those options are preferable to what we have now. Neither would resolve the problem of focus jumping around the screen.
- πΊπΈUnited States swirt Florida
I am moving this issue to the mermaid_diagram_field module because that no covers the use of the Mermaid library and rendering.
Ultimately I think this is a limitation of the Mermaid library itself as the ordering is not anything that can be solved in this module at this time.