@rolster/react-components 18.15.12 → 18.15.13

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/dist/es/index.js CHANGED
@@ -2073,7 +2073,6 @@ function useListControl({ suggestions, formControl }) {
2073
2073
  });
2074
2074
  const collection = useRef(new ListCollection([]));
2075
2075
  const position = useRef(0);
2076
- const changeInternal = useRef(false);
2077
2076
  const protectedValue = useRef();
2078
2077
  useEffect(() => {
2079
2078
  function onCloseSuggestions({ target }) {
@@ -2086,17 +2085,13 @@ function useListControl({ suggestions, formControl }) {
2086
2085
  };
2087
2086
  }, []);
2088
2087
  useEffect(() => {
2089
- formControl?.touch();
2088
+ state.visible && formControl?.touch();
2090
2089
  setState((state) => ({
2091
2090
  ...state,
2092
2091
  higher: locationListCanTop(contentRef.current, listRef.current)
2093
2092
  }));
2094
2093
  }, [state.visible]);
2095
2094
  useEffect(() => {
2096
- if (changeInternal.current) {
2097
- changeInternal.current = false;
2098
- return;
2099
- }
2100
2095
  collection.current = new ListCollection(suggestions);
2101
2096
  refresh(collection.current, formControl?.value);
2102
2097
  }, [suggestions, formControl?.value]);
@@ -2106,12 +2101,13 @@ function useListControl({ suggestions, formControl }) {
2106
2101
  }
2107
2102
  const element = collection.find(state);
2108
2103
  if (element) {
2104
+ protectedValue.current = undefined;
2109
2105
  return setValue(element.description);
2110
2106
  }
2111
2107
  if (!refreshProtected(collection)) {
2112
2108
  protectedValue.current = state;
2113
2109
  setValue('');
2114
- setFormState(undefined);
2110
+ setFormValue(undefined);
2115
2111
  }
2116
2112
  }
2117
2113
  function refreshProtected(collection) {
@@ -2131,11 +2127,8 @@ function useListControl({ suggestions, formControl }) {
2131
2127
  function setValue(value) {
2132
2128
  setState((state) => ({ ...state, value }));
2133
2129
  }
2134
- function setFormState(value) {
2135
- if (formControl) {
2136
- changeInternal.current = true;
2137
- formControl.setValue(value);
2138
- }
2130
+ function setFormValue(value) {
2131
+ formControl?.setValue(value);
2139
2132
  }
2140
2133
  function setVisible(visible) {
2141
2134
  setState((state) => ({ ...state, visible }));
@@ -2167,7 +2160,7 @@ function useListControl({ suggestions, formControl }) {
2167
2160
  navigationElement,
2168
2161
  navigationInput,
2169
2162
  setFocused,
2170
- setFormState,
2163
+ setFormValue,
2171
2164
  setValue,
2172
2165
  setVisible
2173
2166
  };
@@ -2184,7 +2177,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2184
2177
  previous: null
2185
2178
  });
2186
2179
  const listControl = useListControl({ suggestions, formControl });
2187
- const { inputRef, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
2180
+ const { inputRef, navigationElement, navigationInput, setFocused, setFormValue, setValue, setVisible } = listControl;
2188
2181
  useEffect(() => {
2189
2182
  refreshCoincidences(pattern, true);
2190
2183
  }, [suggestions]);
@@ -2219,7 +2212,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2219
2212
  function onClickAction() {
2220
2213
  setVisible(false);
2221
2214
  setValue('');
2222
- setFormState(undefined);
2215
+ setFormValue(undefined);
2223
2216
  onValue && onValue(undefined);
2224
2217
  }
2225
2218
  function onClickBackdrop() {
@@ -2241,7 +2234,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2241
2234
  onSelect(value);
2242
2235
  }
2243
2236
  else {
2244
- setFormState(value);
2237
+ setFormValue(value);
2245
2238
  setValue(description);
2246
2239
  }
2247
2240
  onValue && onValue(value);
@@ -2488,7 +2481,7 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
2488
2481
 
2489
2482
  function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2490
2483
  const listControl = useListControl({ suggestions, formControl });
2491
- const { inputRef, visible, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
2484
+ const { inputRef, visible, navigationElement, navigationInput, setFocused, setFormValue, setValue, setVisible } = listControl;
2492
2485
  function onFocusInput() {
2493
2486
  setFocused(true);
2494
2487
  }
@@ -2537,7 +2530,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2537
2530
  onSelect(value);
2538
2531
  }
2539
2532
  else {
2540
- setFormState(value);
2533
+ setFormValue(value);
2541
2534
  setValue(description);
2542
2535
  }
2543
2536
  onValue && onValue(value);