Skip to content
Snippets Groups Projects
Unverified Commit 25e5f704 authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

Fix scalar error when rendering null (#13808)

* fix scalar error when rendering null

* remove ".only" from test

* make check for null more explicit
parent 80c89bf7
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,16 @@ class VisualizationError extends Component {
/>
);
}
} else if (error instanceof Error) {
return (
<div className={cx(className, "QueryError2 flex justify-center")}>
<div className="QueryError-image QueryError-image--queryError mr4" />
<div className="QueryError2-details">
<h1 className="text-bold">{t`There was a problem with this visualization`}</h1>
<ErrorDetails className="pt2" details={error} />
</div>
</div>
);
} else if (
card &&
card.dataset_query &&
......
......@@ -206,7 +206,9 @@ export default class Scalar extends Component {
// use the compact version of formatting if the component is narrower than
// the cutoff and the formatted value is longer than the cutoff
const displayCompact =
fullScalarValue.length > COMPACT_MIN_LENGTH && width < COMPACT_MAX_WIDTH;
fullScalarValue !== null &&
fullScalarValue.length > COMPACT_MIN_LENGTH &&
width < COMPACT_MAX_WIDTH;
const displayValue = displayCompact ? compactScalarValue : fullScalarValue;
const clicked = {
......
......@@ -51,4 +51,16 @@ describe("MetricForm", () => {
);
getByText("12.3k");
});
it("should render null", () => {
const { getByText } = render(
<Scalar
isDashboard // displays title
series={series(null)}
settings={settings}
visualizationIsClickable={() => false}
/>,
);
getByText("Scalar Title"); // just confirms that it rendered
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment