Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-gitgraph-branch-label-alignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mermaid': patch
---

fix: Align branch label background with text for multi-line labels in LR GitGraph layout
15 changes: 15 additions & 0 deletions cypress/integration/rendering/gitGraph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2164,4 +2164,19 @@ gitGraph TB:
);
});
});

it('97: should render branch labels with multi-line text aligned with background in LR layout', () => {
imgSnapshotTest(
`gitGraph LR:
commit id: "1"
branch "Feature A\n(ongoing)"
commit id: "2"
commit id: "3"
checkout main
commit id: "4"
commit id: "5"
`,
{}
);
});
});
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/git/gitGraphRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ const drawBranches = (
bkg.attr('x', pos - bbox.width / 2 - 10).attr('y', maxPos);
label.attr('transform', 'translate(' + (pos - bbox.width / 2 - 5) + ', ' + maxPos + ')');
} else {
bkg.attr('transform', 'translate(' + -19 + ', ' + (pos - bbox.height / 2) + ')');
bkg.attr('transform', 'translate(' + -19 + ', ' + (pos - 11) + ')');
}
});
};
Expand Down
Loading