Skip to content

Commit

Permalink
fixed issue where gatherOnMount would not gather after a reset
Browse files Browse the repository at this point in the history
  • Loading branch information
joepuzzo committed Oct 25, 2022
1 parent e692320 commit 1b482b2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.35.1 (Oct 25th, 2022)

- fixed issue where gatherOnMount would not gather after a reset

## 4.35.0 (Oct 19th, 2022)

- added ability to setValueQuietly
Expand Down
5 changes: 5 additions & 0 deletions src/FormController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,11 @@ export class FormController {
this.state.valid = ObjectMap.empty(this.state.errors);
this.state.invalid = !this.state.valid;

if (meta.gatherData && meta.gatherOnMount === true) {
// Get error to determine if we even want to validateAsync
this.debouncedGatherInfo(name);
}

this.emit('field', name);

// Special event when fields value changes ( its a reset so it changes )
Expand Down
38 changes: 27 additions & 11 deletions stories/Inputs/GoogleApi/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import React, { useState } from 'react';
import withDocs from '../../utils/withDocs';
import readme from './README.md';

import { Form, Input, Debug, DebugField, useFieldState } from '../../../src';

const googleAutocomplete = async text =>
new Promise((resolve, reject) => {
// console.log('GATHER', text);

if (!text) {
return reject('Need valid text input');
}
Expand Down Expand Up @@ -40,6 +42,7 @@ const AddressSearch = () => {
list="addresses"
name="address"
label="Address:"
// gatherOnMount
gatherData={googleAutocomplete}
/>
{data && (
Expand All @@ -53,15 +56,28 @@ const AddressSearch = () => {
);
};

const InputExample = () => (
<Form autoComplete="off">
<AddressSearch />
<button type="submit">Submit</button>
<h3>Form State:</h3>
<Debug values data gathering />
<h3>Field State:</h3>
<DebugField name="address" gathering data value />
</Form>
);
const InputExample = () => {
// const [initialValues, setInitialValues] = useState();

return (
<Form autoComplete="off">
<AddressSearch />
{/* <button
type="button"
onClick={() =>
setInitialValues({
address: '111'
})
}>
Change
</button> */}
<button type="submit">Submit</button>
<h3>Form State:</h3>
<Debug values data gathering />
<h3>Field State:</h3>
<DebugField name="address" gathering data value />
</Form>
);
};

export default withDocs(readme, InputExample);

0 comments on commit 1b482b2

Please sign in to comment.