The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Clear ChartSettingSelect display value on remove (#70957)
Nick Fitzpatrickb0deebf2b67f
diff --git a/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.jsx b/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.jsxindex 6e5a7de198f..df56b1e4bd8 100644--- a/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.jsx+++ b/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.jsx@@ -58,7 +58,7 @@ export const ChartSettingSelect = ({data={data}dropdownComponent={dropdownComponent}disabled={disabled}- value={encodeWidgetValue(value)}+ value={value === null ? value : encodeWidgetValue(value)}//Mantine V7 select onChange has 2 arguments passed. This breaks the assumption in visualizations/lib/settings.js where the onChange function is definedonChange={(v) => onChange(decodeWidgetValue(v))}placeholder={options.length === 0 ? placeholderNoOptions : placeholder}diff --git a/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.unit.spec.jsx b/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.unit.spec.jsxindex b238277e2f2..e0515261524 100644--- a/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.unit.spec.jsx+++ b/frontend/src/metabase/visualizations/components/settings/ChartSettingSelect.unit.spec.jsx@@ -128,4 +128,31 @@ describe("ChartSettingSelect", () => {);expect(screen.getByTestId("chart-setting-select")).toBeDisabled();});++ it("should show placeholder text when value is cleared", () => {+ const simpleOptions = [+ { name: "Option 1", value: "value1" },+ { name: "Option 2", value: "value2" },+ ];+ const { rerender } = render(+ <ChartSettingSelect+ options={simpleOptions}+ value="value1"+ onChange={jest.fn()}+ placeholder="Pick a value"+ />,+ );+ expect(screen.getByDisplayValue("Option 1")).toBeInTheDocument();++ rerender(+ <ChartSettingSelect+ options={simpleOptions}+ value={null}+ onChange={jest.fn()}+ placeholder="Pick a value"+ />,+ );++ expect(screen.getByPlaceholderText("Pick a value")).toHaveValue("");+ });});