EnxDev commented on code in PR #45168:
URL: https://github.com/apache/superset/pull/45168#discussion_r4276175548


##########
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx:
##########
@@ -570,19 +617,32 @@ const AsyncSelect = forwardRef(
 
           if (allowNewOptions) {
             const unquotedSearch = stripSurroundingQuotes(searchValue);
-            const newOption = unquotedSearch &&
-              !hasOption(unquotedSearch, fullSelectOptions, true) && {
-                label: unquotedSearch,
-                value: unquotedSearch,
-                isNewOption: true,
-              };
-            const cleanSelectOptions = fullSelectOptions.filter(
-              opt => !opt.isNewOption || hasOption(opt.value, selectValue),
-            );
-            const newOptions = newOption
-              ? [newOption, ...cleanSelectOptions]
-              : cleanSelectOptions;
-            setSelectOptions(newOptions);
+            setSelectOptions(prevOptions => {
+              const optionsToCheck = caseSensitiveNewOptionMatching
+                ? fullSelectOptions
+                : [...fullSelectOptions, ...prevOptions];

Review Comment:
   `prevOptions` still holds the optimistic option from the previous keystroke, 
so it counts as a match here. Type `my dashboard`, wait for the debounce, then 
fix it to `My Dashboard`: the old option matches, `cleanSelectOptions` drops it 
because it isn't selected, and the user is left with no create option at all.
   
   Could the check skip new options that aren't selected, e.g. 
`[...cleanSelectOptions, ...prevOptions.filter(option => 
!option.isNewOption)]`? A test that types, waits, then retypes with different 
casing would pin it.



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