You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/07/16 22:26:22 UTC

(superset) branch master updated: fix(alerts): show typed text in email recipients selector (#42091)

This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new edca579625a fix(alerts): show typed text in email recipients selector (#42091)
edca579625a is described below

commit edca579625a15d3d260d92460db3ad1c607b3d39
Author: Joe Li <jo...@preset.io>
AuthorDate: Thu Jul 16 15:26:15 2026 -0700

    fix(alerts): show typed text in email recipients selector (#42091)
    
    Co-authored-by: Claude Fable 5 <no...@anthropic.com>
---
 .../alerts/components/NotificationMethod.tsx       |   3 +-
 .../NotificationMethodEmailRecipients.test.tsx     | 102 +++++++++++++++++++++
 2 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/superset-frontend/src/features/alerts/components/NotificationMethod.tsx b/superset-frontend/src/features/alerts/components/NotificationMethod.tsx
index 244f5f5f120..c20e58d273f 100644
--- a/superset-frontend/src/features/alerts/components/NotificationMethod.tsx
+++ b/superset-frontend/src/features/alerts/components/NotificationMethod.tsx
@@ -112,8 +112,7 @@ const StyledNotificationMethod = styled.div`
       flex-direction: column;
       align-items: stretch;
 
-      .email-recipient-select,
-      .email-recipient-select > div {
+      .email-recipient-select {
         width: 100%;
       }
 
diff --git a/superset-frontend/src/features/alerts/components/NotificationMethodEmailRecipients.test.tsx b/superset-frontend/src/features/alerts/components/NotificationMethodEmailRecipients.test.tsx
new file mode 100644
index 00000000000..083b9f1c377
--- /dev/null
+++ b/superset-frontend/src/features/alerts/components/NotificationMethodEmailRecipients.test.tsx
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// Unlike NotificationMethod.test.tsx, this file intentionally renders the
+// real AsyncSelect so it can catch regressions in the interaction between
+// the alerts CSS and the antd Select internals.
+import fetchMock from 'fetch-mock';
+import {
+  render,
+  screen,
+  userEvent,
+  waitFor,
+} from 'spec/helpers/testing-library';
+import { NotificationMethod } from './NotificationMethod';
+import { NotificationMethodOption, NotificationSetting } from '../types';
+
+const RELATED_USERS_ENDPOINT = 'glob:*/api/v1/report/related/created_by?*';
+
+const emailSetting: NotificationSetting = {
+  method: NotificationMethodOption.Email,
+  recipients: '',
+  options: [NotificationMethodOption.Email, NotificationMethodOption.Slack],
+};
+
+const renderComponent = () =>
+  render(
+    <NotificationMethod
+      setting={emailSetting}
+      index={0}
+      onUpdate={jest.fn()}
+      onRemove={jest.fn()}
+      onInputChange={jest.fn()}
+      email_subject=""
+      defaultSubject=""
+      setErrorSubject={jest.fn()}
+    />,
+  );
+
+fetchMock.get(RELATED_USERS_ENDPOINT, {
+  result: [
+    {
+      text: 'Admin User',
+      value: 1,
+      extra: { email: 'admin@example.com', active: true },
+    },
+  ],
+  count: 1,
+});
+
+test('typed email stays visible in the recipients field and becomes an option', async () => {
+  renderComponent();
+
+  const input = screen.getByRole('combobox', { name: 'Email recipients' });
+  await userEvent.click(input);
+  // AsyncSelect debounces its search handler and cancels the pending call
+  // whenever it re-renders, so wait for the initial options fetch to settle
+  // (its option is visible) before typing to guarantee the search is
+  // processed.
+  await screen.findByRole('option', {
+    name: /Admin User <admin@example\.com>/,
+  });
+  await userEvent.type(input, 'joe@example.com');
+
+  expect(input).toHaveValue('joe@example.com');
+  await waitFor(() =>
+    expect(
+      screen.getByRole('option', { name: /joe@example\.com/ }),
+    ).toBeInTheDocument(),
+  );
+});
+
+test('alerts CSS does not override the width of antd Select internals', () => {
+  // The email recipient selector once used an `.email-recipient-select > div`
+  // rule written for the antd v5 DOM. In the antd v6 DOM that rule matched
+  // `.ant-select-content` instead, collapsing it (and the search input) to
+  // zero width, so typed recipient emails were invisible.
+  const { container } = renderComponent();
+
+  const select = container.querySelector('.email-recipient-select');
+  expect(select).toBeInTheDocument();
+
+  const internalDivs = Array.from(select!.querySelectorAll(':scope > div'));
+  expect(internalDivs.length).toBeGreaterThan(0);
+  internalDivs.forEach(div => {
+    expect(getComputedStyle(div).width).not.toBe('100%');
+  });
+});