Skip to content

Commit

Permalink
Merge pull request #5856 from mermaid-js/5787_firefox_label_width
Browse files Browse the repository at this point in the history
#5787 Fix for issue with labels in firefox
  • Loading branch information
ashishjain0512 authored Sep 12, 2024
2 parents dd03043 + bfd8c63 commit 17c6ed6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dry-plums-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mermaid': minor
---

Fix for issue with calculation of label width when using in firefox
7 changes: 6 additions & 1 deletion packages/mermaid/src/rendering-util/createText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ function applyStyle(dom, styleFn) {

async function addHtmlSpan(element, node, width, classes, addBackground = false) {
const fo = element.append('foreignObject');
// This is not the final width but used in order to make sure the foreign
// object in firefox gets a width at all. The final width is fetched from the div
fo.attr('width', `${10 * width}px`);
fo.attr('height', `${10 * width}px`);

const div = fo.append('xhtml:div');
let label = node.label;
if (node.label && hasKatex(node.label)) {
Expand Down Expand Up @@ -201,7 +206,7 @@ export const createText = async (
} = {},
config: MermaidConfig
) => {
log.info(
log.debug(
'XYZ createText',
text,
style,
Expand Down

0 comments on commit 17c6ed6

Please sign in to comment.