react-core-ts 2.1.45 → 2.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,6 +113,8 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
113
113
 
114
114
  const isSelectingRef = useRef(false);
115
115
  const hasUserChangedInputRef = useRef(false); // Track if user has actually typed/changed input
116
+ const requestIdRef = useRef(0);
117
+ const lastQueryRef = useRef<string | null>(null);
116
118
  const [dropPosition, setDropPosition] = useState<any>({
117
119
  top: 0,
118
120
  left: 0,
@@ -176,6 +178,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
176
178
  hasUserChangedInputRef.current = true; // Mark that user has changed the input
177
179
 
178
180
  setInputValue(value);
181
+ discardStaleSuggestions(value);
179
182
  handleValChange(value);
180
183
  if (!value) {
181
184
  setInputValue('');
@@ -247,17 +250,35 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
247
250
  setSuggestions(filteredData);
248
251
  }
249
252
  };
253
+ // Results from a previous search must not show while a new, unrelated search is pending.
254
+ const discardStaleSuggestions = (value: string) => {
255
+ if (type !== 'auto_complete' || isStaticList) return;
256
+ const next = value.trim().toLowerCase();
257
+ const last = lastQueryRef.current;
258
+ if (!next || last === null || !next.startsWith(last)) {
259
+ requestIdRef.current += 1;
260
+ lastQueryRef.current = null;
261
+ setSuggestions([]);
262
+ setIsLoading(false);
263
+ }
264
+ };
265
+
250
266
  const handlePickSuggestions = async (value?: string) => {
251
267
  if (getData) {
268
+ const requestId = ++requestIdRef.current;
252
269
  setIsLoading(true);
253
270
  try {
254
271
  const fetchedSuggestions = await getData?.(value);
272
+ if (requestId !== requestIdRef.current) return;
255
273
  setSuggestions(fetchedSuggestions);
274
+ lastQueryRef.current =
275
+ !value || value === '*' ? '' : value.trim().toLowerCase();
256
276
  setIsLoading(false);
257
277
  if (autoDropdown) {
258
278
  setRefetchData(true);
259
279
  }
260
280
  } catch (error) {
281
+ if (requestId !== requestIdRef.current) return;
261
282
  setIsLoading(false);
262
283
  }
263
284
  }
@@ -302,6 +323,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
302
323
  data?.push(element);
303
324
  });
304
325
  setSuggestions(fetchedSuggestions);
326
+ lastQueryRef.current = '';
305
327
  setIsLoading(false);
306
328
  if (autoDropdown) {
307
329
  setRefetchData(false);
@@ -438,7 +438,8 @@ ul {
438
438
  position: absolute;
439
439
  top: 50%;
440
440
  left: 8px;
441
- right: 32px;
441
+ right: auto;
442
+ max-width: calc(100% - 40px);
442
443
  transform: translateY(-50%);
443
444
  z-index: 99;
444
445
  flex-wrap: nowrap;
@@ -447,6 +448,15 @@ ul {
447
448
  pointer-events: none;
448
449
  }
449
450
 
451
+ .selected-items-outer-container.selected-items-inline.selected-items-inline-editable {
452
+ max-width: calc(100% - 130px);
453
+ }
454
+
455
+ .qbs-input-with-inline-chips {
456
+ padding-right: 56px;
457
+ text-overflow: ellipsis;
458
+ }
459
+
450
460
  .selected-items-inline .selected-items-container {
451
461
  position: static;
452
462
  flex-shrink: 0;