sadpandajoe commented on code in PR #43722:
URL: https://github.com/apache/superset/pull/43722#discussion_r3913276193
##########
superset-frontend/plugins/plugin-chart-handlebars/src/Handlebars.tsx:
##########
@@ -37,7 +37,22 @@ export default function Handlebars(props: HandlebarsProps) {
const handlebarTemplateSource = formData.handlebarsTemplate
? formData.handlebarsTemplate
: '{{data}}';
- const templateSource = `${handlebarTemplateSource}\n${styleTemplateSource} `;
+ // Markdown only treats `<style>` as a raw-text block that may contain blank
+ // lines when the tag starts a block of its own. Joined to the template by a
+ // single newline, a template opening with an HTML tag absorbed the tag into
+ // its own block instead, so the first blank line in the CSS closed that
+ // block and every rule after it was parsed as Markdown and rendered as
+ // visible chart content. A blank line ends the template's block first, so
+ // the style block starts one of its own.
+ //
+ // The separator is added only when there is CSS to append: a blank line at
+ // the end of the template is not always inert, and appending one when the
+ // chart has no CSS at all would be a change to every existing template for
+ // no reason. Keep the style block last so the template stays first in the
+ // DOM, where positional selectors and cascade order expect it.
+ const templateSource = styleTemplateSource
+ ? `${handlebarTemplateSource}\n\n${styleTemplateSource} `
Review Comment:
Whitespace control in a valid saved template can remove the separator this
relies on. With `</table>{{!-- comment --~}}`, compilation joins `<style>`
directly to the table again, so an internal CSS blank line is parsed as
Markdown; could the CSS be appended after Handlebars expansion (or this case be
covered) so the fix still holds?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]