Skip to content

Commit

Permalink
fix: Allow empty CSS in Handlebars (#22422)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Dec 14, 2022
1 parent ebaa949 commit bb318cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export const ControlHeader = ({
children,
}: ControlHeaderProps): JSX.Element => (
<div className="ControlHeader">
<div className="pull-left">
<span role="button">{children}</span>
</div>
<div className="pull-left">{children}</div>
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import {
ControlSetItem,
CustomControlConfig,
sharedControls,
InfoTooltipWithTrigger,
} from '@superset-ui/chart-controls';
import { t } from '@superset-ui/core';
import { t, useTheme } from '@superset-ui/core';
import React from 'react';
import { CodeEditor } from '../../components/CodeEditor/CodeEditor';
import { ControlHeader } from '../../components/ControlHeader/controlHeader';
Expand All @@ -32,17 +33,32 @@ interface StyleCustomControlProps {
}

const StyleControl = (props: CustomControlConfig<StyleCustomControlProps>) => {
const val = String(
props?.value ? props?.value : props?.default ? props?.default : '',
);
const theme = useTheme();

const defaultValue = props?.value
? undefined
: `/*
.data-list {
background-color: yellow;
}
*/`;

return (
<div>
<ControlHeader>{props.label}</ControlHeader>
<ControlHeader>
<div>
{props.label}
<InfoTooltipWithTrigger
iconsStyle={{ marginLeft: theme.gridUnit }}
tooltip={t('You need to configure HTML sanitization to use CSS')}
/>
</div>
</ControlHeader>
<CodeEditor
theme="dark"
mode="css"
value={val}
value={props.value}
defaultValue={defaultValue}
onChange={source => {
debounceFunc(props.onChange, source || '');
}}
Expand All @@ -58,11 +74,6 @@ export const styleControlSetItem: ControlSetItem = {
type: StyleControl,
label: t('CSS Styles'),
description: t('CSS applied to the chart'),
default: `/*
.data-list {
background-color: yellow;
}
*/`,
isInt: false,
renderTrigger: true,

Expand Down

0 comments on commit bb318cb

Please sign in to comment.