mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
Merge pull request #6702 from qraqras/bug/6633_remove-unexpected-spaces-in-block-diagram
Fix: Remove unexpected spaces in Block Diagram
This commit is contained in:
8
.changeset/lovely-queens-own.md
Normal file
8
.changeset/lovely-queens-own.md
Normal 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).
|
@@ -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
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user