You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2025/10/03 15:53:17 UTC

(superset) branch msyavuz/fix/select-disappear created (now d613a0aa90)

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

msyavuz pushed a change to branch msyavuz/fix/select-disappear
in repository https://gitbox.apache.org/repos/asf/superset.git


      at d613a0aa90 test(Select): add tests for the fix

This branch includes the following new commits:

     new 0ef0476baf fix(Select): prevent closing the dropdown when clicked on the single tag
     new d613a0aa90 test(Select): add tests for the fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 02/02: test(Select): add tests for the fix

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

msyavuz pushed a commit to branch msyavuz/fix/select-disappear
in repository https://gitbox.apache.org/repos/asf/superset.git

commit d613a0aa9015eb1584a7f8877f9ca02568a2c8c5
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Oct 3 18:52:23 2025 +0300

    test(Select): add tests for the fix
---
 .../src/components/Select/Select.test.tsx          | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx
index 93608a5031..e13c98c547 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx
@@ -779,6 +779,38 @@ test('Renders only an overflow tag if dropdown is open in oneLine mode', async (
   expect(withinSelector.getByText('+ 2 ...')).toBeVisible();
 });
 
+// Test for checking the issue described in: https://github.com/apache/superset/issues/35132
+test('Maintains stable maxTagCount to prevent click target disappearing in oneLine mode', async () => {
+  render(
+    <Select
+      {...defaultProps}
+      value={[OPTIONS[0], OPTIONS[1], OPTIONS[2]]}
+      mode="multiple"
+      oneLine
+    />,
+  );
+
+  const withinSelector = within(getElementByClassName('.ant-select-selector'));
+  expect(withinSelector.getByText(OPTIONS[0].label)).toBeVisible();
+  expect(withinSelector.getByText('+ 2 ...')).toBeVisible();
+
+  await userEvent.click(getSelect());
+  expect(withinSelector.getByText(OPTIONS[0].label)).toBeVisible();
+
+  await waitFor(() => {
+    expect(
+      withinSelector.queryByText(OPTIONS[0].label),
+    ).not.toBeInTheDocument();
+    expect(withinSelector.getByText('+ 3 ...')).toBeVisible();
+  });
+
+  // Close dropdown
+  await type('{esc}');
+
+  expect(await withinSelector.findByText(OPTIONS[0].label)).toBeVisible();
+  expect(withinSelector.getByText('+ 2 ...')).toBeVisible();
+});
+
 test('does not render "Select all" when there are 0 or 1 options', async () => {
   const { rerender } = render(
     <Select {...defaultProps} options={[]} mode="multiple" allowNewOptions />,


(superset) 01/02: fix(Select): prevent closing the dropdown when clicked on the single tag

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

msyavuz pushed a commit to branch msyavuz/fix/select-disappear
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 0ef0476baf62c016efe744ef4b1d6a07ff5dd181
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Oct 3 18:47:04 2025 +0300

    fix(Select): prevent closing the dropdown when clicked on the single tag
---
 .../src/components/Select/Select.tsx               | 33 ++++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
index bf8c99263d..e8300f6eb3 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
@@ -24,6 +24,7 @@ import {
   useMemo,
   useState,
   useCallback,
+  useRef,
   ClipboardEvent,
   Ref,
   ReactElement,
@@ -143,6 +144,32 @@ const Select = forwardRef(
         : 1
       : (propsMaxTagCount ?? MAX_TAG_COUNT);
 
+    // Prevent maxTagCount change during click events to avoid click target disappearing
+    const [stableMaxTagCount, setStableMaxTagCount] = useState(maxTagCount);
+    const isOpeningRef = useRef(false);
+
+    useEffect(() => {
+      if (oneLine) {
+        if (isDropdownVisible && !isOpeningRef.current) {
+          // Mark that we're in the opening process
+          isOpeningRef.current = true;
+          // Use requestAnimationFrame to ensure DOM has settled after the click
+          requestAnimationFrame(() => {
+            setStableMaxTagCount(0);
+            isOpeningRef.current = false;
+          });
+          return;
+        }
+        if (!isDropdownVisible) {
+          // When closing, immediately show the first tag
+          setStableMaxTagCount(1);
+          isOpeningRef.current = false;
+        }
+        return;
+      }
+      setStableMaxTagCount(maxTagCount);
+    }, [maxTagCount, isDropdownVisible, oneLine]);
+
     const mappedMode = isSingleMode ? undefined : 'multiple';
 
     const sortSelectedFirst = useCallback(
@@ -599,16 +626,16 @@ const Select = forwardRef(
 
     const omittedCount = useMemo(() => {
       const num_selected = ensureIsArray(selectValue).length;
-      const num_shown = maxTagCount as number;
+      const num_shown = stableMaxTagCount as number;
       return num_selected - num_shown - (selectAllMode ? 1 : 0);
-    }, [maxTagCount, selectAllMode, selectValue]);
+    }, [stableMaxTagCount, selectAllMode, selectValue]);
 
     const customMaxTagPlaceholder = () =>
       `+ ${omittedCount > 0 ? omittedCount : 1} ...`;
 
     // We can't remove the + tag so when Select All
     // is the only item omitted, we subtract one from maxTagCount
-    let actualMaxTagCount = maxTagCount;
+    let actualMaxTagCount = stableMaxTagCount;
     if (
       actualMaxTagCount !== 'responsive' &&
       omittedCount === 0 &&