fix(AlertReportModal): TypeError when pasting text into the Alerts content form search field (#39298)

Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
This commit is contained in:
jesperct
2026-05-13 11:38:55 -03:00
committed by GitHub
parent 940779ad5f
commit 6cebba49ca
2 changed files with 31 additions and 2 deletions

View File

@@ -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(<AlertReportModal {...generateMockedProps(false, true, false)} />, {
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(<AlertReportModal {...generateMockedProps(false, true, false)} />, {
useRedux: true,

View File

@@ -1270,10 +1270,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
[],
);
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<AlertReportModalProps> = ({
<AsyncSelect
ariaLabel={t('Chart')}
name="chart"
allowClear
value={
currentAlert?.chart?.label &&
currentAlert?.chart?.value