Closed (works as designed)
Project:
Drupal Canvas
Version:
1.x-dev
Component:
Theme builder
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 May 2026 at 12:18 UTC
Updated:
15 May 2026 at 07:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #5
bnjmnmClosing MR 1072 - appreciate the attempt @shubham.prakash but I don't want to create the impression that the solution is in that part of the codebase. It is a popular diagnosis destination but rarely where the fix ultimately happens.
If this issue is only occurring with code components then it's likely React doing it's job - it escapes HTML by default. You'd need to use dangerouslySetInnerHTML for this to show up like you'd expect. It's possible there's something in the code component API to be used instead of
dangerouslySetInnerHTML, but React escaping an HTML string is a feature, not a bug 🤓If the above doesn't seem accurate, please provide the component where this is happening.
Comment #6
effulgentsia commentedI'm assuming this is a Code Component that's on the site. Canvas itself doesn't ship with any default Code Components. What's the JS code for this component? If it's something like:
then that would cause what this issue is describing, but that's by design per #5. The code instead needs to be:
where FormattedText is imported per https://project.pages.drupalcode.org/canvas/code-components/packages/#fo....
Comment #7
penyaskitoPer #5, #6, changing status and category.
Comment #8
mayur-sose commented@effulgentsia @bnjmnm @penyaskito
Below is the JS code component for reference:
Comment #9
effulgentsia commentedThanks @mayur-sose,
That component needs to be fixed to:
import { FormattedText } from 'drupal-canvas';at the top.formattedTexttoFormattedText(capitalize the F).In other words, the new code should be:
Can you try that out and report back if that solves it?
Comment #10
mayur-sose commentedThe changes above resolve the issue. Thanks @effulgentsia!
Comment #12
penyaskitoThis has come quite a few times already (happened to myself too in the past, but I was able to figure out).
Wondering if there's something we can do UX-wise to make things easier, but can't think of anything TBF.