@rolster/react-components 18.10.6 → 18.10.7

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
@@ -1279,16 +1279,14 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
1279
1279
  useEffect(() => filterSuggestions(pattern, true), [suggestions]);
1280
1280
  useEffect(() => filterSuggestions(pattern), [pattern]);
1281
1281
  useEffect(() => {
1282
- changeInternal
1283
- ? setChangeInternal(false)
1284
- : reset(collection, formControl?.state);
1282
+ changeInternal ? setChangeInternal(false) : resetState(formControl?.state);
1285
1283
  }, [formControl?.state]);
1286
- useEffect(() => reset(collection, formControl?.state), [collection]);
1284
+ useEffect(() => resetCollection(collection, formControl?.state), [collection]);
1287
1285
  function setFormState(value) {
1288
1286
  setChangeInternal(true);
1289
1287
  formControl?.setState(value);
1290
1288
  }
1291
- function reset(collection, state) {
1289
+ function resetCollection(collection, state) {
1292
1290
  if (state) {
1293
1291
  const element = collection.find(state);
1294
1292
  if (element) {
@@ -1303,6 +1301,9 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
1303
1301
  setValue('');
1304
1302
  }
1305
1303
  }
1304
+ function resetState(state) {
1305
+ setValue(state ? collection.find(state)?.description || '' : '');
1306
+ }
1306
1307
  function onClickControl() {
1307
1308
  if (!disabled) {
1308
1309
  setVisible(true);
@@ -1894,16 +1895,14 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1894
1895
  const { collection, inputRef, visible, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
1895
1896
  const [changeInternal, setChangeInternal] = useState(false);
1896
1897
  useEffect(() => {
1897
- changeInternal
1898
- ? setChangeInternal(false)
1899
- : reset(collection, formControl?.state);
1898
+ changeInternal ? setChangeInternal(false) : resetState(formControl?.state);
1900
1899
  }, [formControl?.state]);
1901
- useEffect(() => reset(collection, formControl?.state), [collection]);
1900
+ useEffect(() => resetCollection(collection, formControl?.state), [collection]);
1902
1901
  function setFormState(value) {
1903
1902
  setChangeInternal(true);
1904
1903
  formControl?.setState(value);
1905
1904
  }
1906
- function reset(collection, state) {
1905
+ function resetCollection(collection, state) {
1907
1906
  if (state) {
1908
1907
  const element = collection.find(state);
1909
1908
  if (element) {
@@ -1918,6 +1917,9 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1918
1917
  setValue('');
1919
1918
  }
1920
1919
  }
1920
+ function resetState(state) {
1921
+ setValue(state ? collection.find(state)?.description || '' : '');
1922
+ }
1921
1923
  function onFocusInput() {
1922
1924
  setFocused(true);
1923
1925
  }