diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go
index f42c68eed..9d70eb837 100644
--- a/d2layouts/d2sequence/sequence_diagram.go
+++ b/d2layouts/d2sequence/sequence_diagram.go
@@ -224,6 +224,7 @@ func (sd *sequenceDiagram) placeSpans() {
// routeMessages routes horizontal edges (messages) from Src to Dst
func (sd *sequenceDiagram) routeMessages() {
for rank, message := range sd.messages {
+ message.ZIndex = 2
isLeftToRight := message.Src.TopLeft.X < message.Dst.TopLeft.X
// finds the proper anchor point based on the message direction
diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json
index 61003c046..f91a979ec 100644
--- a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json
+++ b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json
@@ -920,7 +920,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(itemResponse.a -> item.a.b)[0]",
@@ -959,7 +959,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(item.a.b -> essayRubric.a.b.c)[0]",
@@ -998,7 +998,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(essayRubric.a.b.c -> concept.a.b.c.d)[0]",
@@ -1037,7 +1037,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(item.a -> essayRubric.a.b)[0]",
@@ -1076,7 +1076,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(concept.a.b.c.d -> itemOutcome.a.b.c.d.e)[0]",
@@ -1115,7 +1115,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(scorer.abc -> item.a)[0]",
@@ -1154,7 +1154,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(itemOutcome.a.b.c.d.e -> scorer)[0]",
@@ -1193,7 +1193,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(scorer -> itemResponse.c)[0]",
@@ -1232,7 +1232,7 @@
"animated": false,
"tooltip": "",
"icon": null,
- "zIndex": 0
+ "zIndex": 2
},
{
"id": "(scorer -- )[0]",
diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg
index 6c954c961..a4cc51663 100644
--- a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg
+++ b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg
@@ -14,7 +14,7 @@ width="2516" height="1841" viewBox="-100 -50 2516 1841">scoreritemResponseitemessayRubricconceptitemOutcome scoreritemResponseitemessayRubricconceptitemOutcome scoreritemResponseitemessayRubricconceptitemOutcome scoreritemResponseitemessayRubricconceptitemOutcome AlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication ResponseAlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication ResponseAlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication ResponseAlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication ResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)