react-core-ts 1.6.2 → 1.6.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-core-ts",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "React Components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -104,6 +104,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
104
104
  const [selectedIndex, setSelectedIndex] = useState(0);
105
105
  const itemRefs = useRef<(HTMLLIElement | null)[]>([]);
106
106
  const scrollContainerRef = useRef<HTMLUListElement | null>(null);
107
+ const [refetchData, setRefetchData] = useState(false);
107
108
  const [dropPosition, setDropPosition] = useState<any>({
108
109
  top: 0,
109
110
  left: 0,
@@ -234,6 +235,9 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
234
235
  const fetchedSuggestions = await getData?.(value);
235
236
  setSuggestions(fetchedSuggestions);
236
237
  setIsLoading(false);
238
+ if (autoDropdown) {
239
+ setRefetchData(true);
240
+ }
237
241
  } catch (error) {
238
242
  setIsLoading(false);
239
243
  }
@@ -268,15 +272,21 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
268
272
  else return (inputValue?.toString().length ?? 0) <= 0 ? true : false;
269
273
  };
270
274
  const loadStaticData = async () => {
271
- if (!data) {
275
+ if (!data || (refetchData && autoDropdown && !isStaticList)) {
272
276
  data = [];
273
277
  if (getData) {
274
278
  try {
275
279
  setIsLoading(true);
276
280
  //handlePickSuggestions('*');
277
281
  const fetchedSuggestions = await getData?.("*");
282
+ fetchedSuggestions?.forEach((element: any) => {
283
+ data?.push(element);
284
+ });
278
285
  setSuggestions(fetchedSuggestions);
279
286
  setIsLoading(false);
287
+ if (autoDropdown) {
288
+ setRefetchData(false);
289
+ }
280
290
  } catch (error) {
281
291
  setIsLoading(false);
282
292
  }
@@ -332,7 +342,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
332
342
  };
333
343
 
334
344
  const handleOpenDropdown = (e: any) => {
335
- if (!suggestions || suggestions?.length === 0) {
345
+ if (!suggestions || suggestions?.length === 0 || refetchData) {
336
346
  if (autoDropdown && (inputValue === "" || inputValue.trim() === "")) {
337
347
  loadStaticData();
338
348
  } else {
@@ -383,6 +393,9 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
383
393
  setInputValue("");
384
394
  onChange({ id: undefined, name: "", from: 3 });
385
395
  onLabelClick();
396
+ if(autoDropdown) {
397
+ setRefetchData(true);
398
+ }
386
399
  };
387
400
 
388
401
  useEffect(() => {