Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Render with FontAwesome Icons overflows labels #2651

Open
RickStrahl opened this issue Jan 20, 2022 · 9 comments
Open

Initial Render with FontAwesome Icons overflows labels #2651

RickStrahl opened this issue Jan 20, 2022 · 9 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@RickStrahl
Copy link

RickStrahl commented Jan 20, 2022

When rendering charts with wide FontAwesome icons, on initial render text that follows the icons often overflows the space allocated for the text resulting in truncated labels.

image

Breaking into the code and slightly delaying the render process has no effect. What appears to be happening is that Mermaid renders the labels without the icons (or the square placeholders) and then the icons get loaded afterwards essentially pushing the text out of the allocated render box. Delaying even for several seconds to ensure fontawesome has completely loaded seems to have no effect on this behavior.

  • Content loads
  • Mermaid renders and renders correctly without FontAwesome icons (fixed squares show)
  • Then the icons pop in after and push the content out of its box

My first thought was that FA isn't yet loaded, but even delaying execution by several seconds did not fix this so it has to be something inside of Mermaid that happens with the FA font rendering.

Additionally, it looks like this only occurs on first render. If you reload charts dynamically in the page (ie. replacing or updating chant content without reloading the entire page) and then render again the icons and labels render correctly (see JsFiddle and steps below). It all feels like a timing issue of when the FA icons become available, not just to the page but within Mermaid.

Reproduce

I've put together a JsFiddle that basically does what MM does in a more simplified way:

https://jsfiddle.net/rstrahl/h7gL4b0m/14/

To see the problem in the fiddle:

  • Load the page once (see cut off labels - FAIL)
  • Make a change and save or re-run (labels not cut off - GOOD)
  • Now refresh the browser
  • Page re-loads completely (see cut of labels - FAIL)

No matter how long the timeout I put the font-awesome icons push the text out of the graphic label space.

The JsFiddle Change and save apparently doesn't reload the entire page, but just replaces the base content, so the Mermaid initialization script code doesn't run again which is similar to my application that is hosting Mermaid.

Re-rendering when nothing has changed in the document does not work. So if setTimeout(renderMermaid,10000); that doesn't actually refresh because it looks like Mermaid tracks what it has rendered already.

Platform: Windows

Update

This behavior can also be seen in the Mermaid Live Editor:

image

Sample on Mermaid Live Editor

Add a [fa:fa-reply-all label] into the chart and you can see the same behavior. it works upon initial editing (page is updated dynamically), but if you then reload the entire page with a Browser Refresh you see the truncated label as per image above.

@dougwaldron
Copy link

In case it helps, I'm seeing this behavior on Edge (chromium) but not Firefox.

@RickStrahl
Copy link
Author

For me it fails in FireFox too:

image

@dougwaldron
Copy link

Ok, I'm seeing the same thing as you now. I must have triggered a redraw somehow without realizing it.

@Yoshanuikabundi
Copy link

Yoshanuikabundi commented Apr 4, 2022

I'm getting this too, but without FA, just with a change of font (and font size): https://openff-interchange--428.org.readthedocs.build/en/428/using/intro.html

Text is only cut off the first time the page is loaded; refreshing seems to fix the issue, and clearing the cache seems to bring it back.

Edit: Source: https://github.com/openforcefield/openff-interchange/blob/docs-rearrange/docs/using/intro.md

@dmoore247
Copy link

I'm also seeing the label overflow too with FontAwesome icons,
it's cutting off the 3 periods when the generated HTML is displayed.
Chrome browser. It's aways there.

image

@fireproofsocks
Copy link

I'm experiencing this too. Mermaid v9.1.4. Padding the labels with #nbsp; does not seem to help.

@sidharthv96
Copy link
Member

image

Issue is also present in mermaid docs.

@dschrempf
Copy link

I can confirm this issue:
image
(The word is "Alignment")

@dschrempf
Copy link

dschrempf commented May 22, 2023

I just saw that the mermaid-cli issue tracker is full of reated issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

7 participants