massucattoj commented on code in PR #39068:
URL: https://github.com/apache/superset/pull/39068#discussion_r3611242649


##########
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx:
##########
@@ -366,6 +387,42 @@ const Select = forwardRef(
       onSelect?.(selectedItem, option);
     };
 
+    // The underlying Select silently drops tokens it cannot match against the
+    // rendered options. That happens whenever tokenization outpaces the
+    // debounced option registration, e.g. dead-key keyboard layouts deliver a
+    // closing quote and a separator in a single input event.
+    reconcileTokensRef.current = (tokens: string[]) => {
+      if (isSingleMode || !allowNewOptions) {
+        return;
+      }
+      setTimeout(() => {
+        tokens.forEach(token => {
+          const matched = getOption(token, fullSelectOptionsRef.current, true);
+          const matchedValue = isObject(matched) ? matched.value : matched;
+          if (hasOption(matchedValue ?? token, selectValueRef.current)) {
+            return;
+          }
+          const option = isObject(matched)
+            ? (matched as AntdLabeledValue)
+            : { label: token, value: token, isNewOption: true };
+          if (!matched) {
+            const addOption = (previous: SelectOptionsType) =>
+              hasOption(token, previous, true)
+                ? previous
+                : [option, ...previous];
+            setSelectOptions(addOption);
+            setVisibleOptions(addOption);
+          }
+          handleOnSelect(
+            (labelInValue
+              ? { label: option.label, value: option.value }
+              : option.value) as string | AntdLabeledValue,
+            option as AntdLabeledValue,
+          );
+        });
+      });

Review Comment:
   The freshness check is already there



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