codeant-ai-for-open-source[bot] commented on code in PR #39068:
URL: https://github.com/apache/superset/pull/39068#discussion_r3591356943


##########
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx:
##########
@@ -721,22 +786,13 @@ const Select = forwardRef(
           setSelectValue(value);
         }
       } else {
+        e.preventDefault();

Review Comment:
   **Suggestion:** Calling `preventDefault` for every multi-select paste event 
swallows normal paste-to-search behavior when pasted content cannot be 
converted into selectable values (for example, unknown text when new options 
are not allowed). In those cases the input is left unchanged and the user loses 
the pasted text entirely. Only prevent default when you are actually consuming 
the paste into tokens/selections, otherwise allow native paste to proceed. 
[logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Native select filters drop pasted unknown text silently.
   - ⚠️ Users lose paste-to-search in non-creatable multi-select filters.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure a native Select filter using `SelectFilterPlugin` from
   `src/filters/components/Select/SelectFilterPlugin.tsx:57-64` with 
`multiSelect=true`,
   `searchAllOptions=false` (default in `types.ts:80-88`), and toggle 
`creatable` off via the
   control panel in `controlPanel.ts:9-18`, so at runtime `allowNewOptions` is 
false and
   `allowNewOptionsOnPaste` is false.
   
   2. On a dashboard, focus this filter’s multi-select input (rendered by 
`Select` from
   `Select.tsx:93`) and paste an unknown value (not present in `options`) into 
the input.
   
   3. The `onPaste` handler at `Select.tsx:781-839` runs; because 
`isSingleMode` is false it
   enters the multi-select branch and calls `e.preventDefault()` at 
`Select.tsx:789`,
   cancelling the browser’s default paste that would insert text into the input.
   
   4. `splitWithQuoteEscaping` and `getPastedTextValue` at `Select.tsx:795-819` 
return an
   empty `values` array when the pasted token is not in `fullSelectOptions` and
   `keepUnknownValues` is false (since both `allowNewOptions` and 
`allowNewOptionsOnPaste`
   are false), so no call to `setSelectValue` or `setInputValue` changes state; 
the paste
   text is discarded while the selection is unchanged, and `fireOnChange()` at
   `Select.tsx:838` runs without any visible effect, leaving the user’s pasted 
input
   irretrievably lost.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0f21fb8c78694cc78fb007163f656f8f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0f21fb8c78694cc78fb007163f656f8f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
   **Line:** 789:789
   **Comment:**
        *Logic Error: Calling `preventDefault` for every multi-select paste 
event swallows normal paste-to-search behavior when pasted content cannot be 
converted into selectable values (for example, unknown text when new options 
are not allowed). In those cases the input is left unchanged and the user loses 
the pasted text entirely. Only prevent default when you are actually consuming 
the paste into tokens/selections, otherwise allow native paste to proceed.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39068&comment_hash=4e84f1469b58ef6e659144f9988af6a2048868456b0628f757ff2e0fed843ecf&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39068&comment_hash=4e84f1469b58ef6e659144f9988af6a2048868456b0628f757ff2e0fed843ecf&reaction=dislike'>👎</a>



##########
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx:
##########
@@ -721,22 +786,13 @@ const Select = forwardRef(
           setSelectValue(value);
         }
       } else {
+        e.preventDefault();
         // antd v6 widened `tokenSeparators` to `string[] | (input => 
string[])`;
         // Superset always uses the array form.
         const separators = Array.isArray(tokenSeparators)
           ? tokenSeparators
           : [];
-        const token = separators.find((token: string) =>
-          pastedText.includes(token),
-        );
-        const array = token
-          ? uniq(
-              pastedText
-                .split(token)
-                .map(item => item.trim())
-                .filter(Boolean),
-            )
-          : [pastedText.trim()].filter(Boolean);
+        const array = uniq(splitWithQuoteEscaping(pastedText, separators));

Review Comment:
   **Suggestion:** This uses a splitter that chooses only one separator for the 
whole pasted string, so mixed-separator payloads (for example quoted CSV plus 
newline-separated values) are parsed incorrectly as a single token or wrong 
chunks. As a result, valid pasted lists may not tokenize as expected. Use 
tokenization that supports all configured separators in one pass (while still 
respecting quoted comma regions). [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Native select filters mis-tokenize mixed-delimiter pasted lists.
   - ⚠️ Some pasted multi-line CSV values become single incorrect option.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Use a multi-select native filter rendered via `SelectFilterPlugin`
   (`src/filters/components/Select/SelectFilterPlugin.tsx:57-69`), which passes
   `tokenSeparators` through to `Select` so it defaults to `TOKEN_SEPARATORS = 
[',', '\r\n',
   '\n', '\t', ';']` defined in `constants.ts:67`.
   
   2. On a dashboard, focus this multi-select filter and paste a string 
containing both
   commas and newlines, for example `"Australia, Austria"\nCanada`, into the 
input so the
   `onPaste` handler in `Select.tsx:781-839` is triggered in the multi-select 
branch.
   
   3. `onPaste` builds `separators` from `tokenSeparators` and calls
   `splitWithQuoteEscaping(pastedText, separators)` at `Select.tsx:792-795`; 
inside
   `splitWithQuoteEscaping` in `utils.tsx:266-297`, the implementation picks 
only the first
   matching separator via `const separator = separators.find(sep => 
text.includes(sep));`,
   which chooses `','` when both `','` and `'\n'` appear.
   
   4. Because only this single separator is honored in the loop at 
`utils.tsx:279-291`,
   commas outside quoted regions are split but newlines are treated as regular 
characters,
   producing a token like `"Australia, Austria"\nCanada` instead of two 
separate values;
   `onPaste` then treats that entire mixed string as one option at 
`Select.tsx:805-819`, so
   the user gets a single chip instead of expected separate entries for 
`"Australia,
   Austria"` and `Canada`.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=30fa275094f0421f87c953a95c862ec4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=30fa275094f0421f87c953a95c862ec4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
   **Line:** 795:795
   **Comment:**
        *Logic Error: This uses a splitter that chooses only one separator for 
the whole pasted string, so mixed-separator payloads (for example quoted CSV 
plus newline-separated values) are parsed incorrectly as a single token or 
wrong chunks. As a result, valid pasted lists may not tokenize as expected. Use 
tokenization that supports all configured separators in one pass (while still 
respecting quoted comma regions).
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39068&comment_hash=93ca550cbce2e1a74deece44d1716054f2f8660447d9eb60bb86c31226c7fe21&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39068&comment_hash=93ca550cbce2e1a74deece44d1716054f2f8660447d9eb60bb86c31226c7fe21&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to