Merge branch 'develop' into sidv/fixID

This commit is contained in:
shubham-mermaid
2025-07-29 15:09:56 +05:30
committed by GitHub
3 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
---
'mermaid': patch
---
fix(block): overflowing blocks no longer affect later lines
This may change the layout of block diagrams that have overflowing lines
(i.e. block diagrams that use up more columns that the `columns` specifier).

View File

@@ -384,4 +384,17 @@ describe('Block diagram', () => {
{}
);
});
it('BL30: block should overflow if too wide for columns', () => {
imgSnapshotTest(
`block-beta
columns 2
fit:2
overflow:3
short:1
also_overflow:2
`,
{}
);
});
});

View File

@@ -270,7 +270,12 @@ function layoutBlocks(block: Block, db: BlockDB) {
if (child.children) {
layoutBlocks(child, db);
}
columnPos += child?.widthInColumns ?? 1;
let columnsFilled = child?.widthInColumns ?? 1;
if (columns > 0) {
// Make sure overflowing lines do not affect later lines
columnsFilled = Math.min(columnsFilled, columns - (columnPos % columns));
}
columnPos += columnsFilled;
log.debug('abc88 columnsPos', child, columnPos);
}
}