diff --git a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
index 76a6527d1ad..0eb7f964df3 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
@@ -701,6 +701,30 @@ test('does not show screenshot width when csv is selected', async () => {
expect(screen.queryByRole('spinbutton')).not.toBeInTheDocument();
});
+test('clearing the chart selection resets the combobox value', async () => {
+ render(, {
+ useRedux: true,
+ });
+ userEvent.click(screen.getByTestId('contents-panel'));
+ await screen.findByText(/test chart/i);
+ const chartCombobox = screen.getByRole('combobox', {
+ name: /Chart: Test Chart/i,
+ });
+ const chartSelectRoot = chartCombobox.closest('.ant-select');
+ expect(chartSelectRoot).toBeInTheDocument();
+ await userEvent.click(
+ within(chartSelectRoot as HTMLElement).getByLabelText('close-circle'),
+ );
+ await waitFor(() => {
+ expect(
+ within(chartSelectRoot as HTMLElement).queryByText(/test chart/i),
+ ).not.toBeInTheDocument();
+ expect(
+ within(chartSelectRoot as HTMLElement).getByText(/select chart to use/i),
+ ).toBeInTheDocument();
+ });
+});
+
test('shows screenshot width when PDF is selected', async () => {
render(, {
useRedux: true,
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index ee300a5380b..64f1fa4024c 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -1270,10 +1270,14 @@ const AlertReportModal: FunctionComponent = ({
[],
);
- const getChartVisualizationType = (chart: SelectValue) =>
- SupersetClient.get({
+ const getChartVisualizationType = (chart: SelectValue) => {
+ if (!chart || typeof chart !== 'object' || chart.value === undefined) {
+ return;
+ }
+ return SupersetClient.get({
endpoint: `/api/v1/chart/${chart.value}`,
}).then(response => setChartVizType(response.json.result.viz_type));
+ };
const updateEmailSubject = () => {
const chartLabel = currentAlert?.chart?.label;
@@ -2341,6 +2345,7 @@ const AlertReportModal: FunctionComponent = ({