bito-code-review[bot] commented on code in PR #39068:
URL: https://github.com/apache/superset/pull/39068#discussion_r3532219877


##########
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx:
##########
@@ -462,11 +479,59 @@ const Select = forwardRef(
         .filter((option): option is AntdLabeledValue => option !== null);
 
       setVisibleOptions(filteredOptions);
-      setInputValue(searchValue);
       onSearch?.(searchValue);
-    }, Constants.FAST_DEBOUNCE);
+    };
+
+    const selectTokenizedValues = (values: string[]) => {
+      const newOptions: SelectOptionsType = [];
+      values.forEach(item => {
+        const option = getOption(item, fullSelectOptions, true);
+        if (!option && !allowNewOptions) return;
+        if (!option) {
+          newOptions.push({ label: item, value: item, isNewOption: true });
+        }
+        const optValue = option
+          ? isObject(option)
+            ? option.value!
+            : option
+          : item;
+        const optLabel = option
+          ? isObject(option)
+            ? option.label
+            : option
+          : item;
+        handleOnSelect(
+          labelInValue ? { label: optLabel, value: optValue } : optValue,
+          { label: optLabel, value: optValue, isNewOption: !option },
+        );
+      });
+      if (newOptions.length > 0) {
+        setSelectOptions(prev => [...newOptions, ...prev]);
+        setVisibleOptions(prev => [...newOptions, ...prev]);
+      }
+    };
 
-    useEffect(() => () => handleOnSearch.cancel(), [handleOnSearch]);
+    const onSearchChange = (search: string) => {
+      // Handle comma tokenization with quote escaping (multi-select only)
+      if (!isSingleMode && tokenSeparators.includes(',')) {
+        const lastCommaIdx = findLastUnquotedSeparatorIndex(search, ',');
+        if (lastCommaIdx !== -1) {
+          const before = search.slice(0, lastCommaIdx);
+          const after = search.slice(lastCommaIdx + 1);
+          const parts = splitWithQuoteEscaping(before, [','])
+            .map(p => p.trim())
+            .filter(Boolean);
+          if (parts.length > 0) {
+            selectTokenizedValues(parts);
+          }
+          setInputValue(after);
+          handleOnSearchDebounced(() => runSearchLogic(after));
+          return;
+        }
+      }
+      setInputValue(search);
+      handleOnSearchDebounced(() => runSearchLogic(search));
+    };

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing test coverage for tokenization</b></div>
   <div id="fix">
   
   The new `onSearchChange`, `selectTokenizedValues`, and `runSearchLogic` 
functions implement comma-based tokenization (selecting tokens as you type) but 
have zero test coverage in `Select.test.tsx`. BITO.md rule [6262] requires 
tests to verify actual business logic, not just that the component renders. 
While the utility functions (`splitWithQuoteEscaping`, 
`findLastUnquotedSeparatorIndex`, `stripSurroundingQuotes`) are tested in 
`utils.test.ts`, the end-to-end behavior — that typing `foo,` selects 'foo' and 
leaves `bar` for search — is never asserted. Add tests covering: comma selects 
token and preserves remaining input, quote-escaped values are treated as 
atomic, debounce is respected, no-op on trailing comma, and single-select mode 
bypasses tokenization.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #21bb50</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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