Skip to content

Commit

Permalink
Fixed issue with initialization code when value was empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
joepuzzo committed Feb 16, 2023
1 parent e819122 commit 1fd1038
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.40.0 (Feb 16th, 2023)

### Fixed

- Fixed issue with initialization code when value was empty string.

## 4.40.0 (Feb 6th, 2023)

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/FormController.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ export class FormController {
// use that ( it was not removed on purpose! )
// Otherwise use the fields initial value
if (
!this.getValue(name) &&
this.getValue(name) === undefined &&
meta.current.initialValue != null &&
(meta.current.initializeValueIfPristine ? this.state.pristine : true)
) {
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useMultistep.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ const useMultistep = ({ initialStep, multistepApiRef }) => {
const goalIndex = stepsMap.get(step).index;
const currIndex = stepsMap.get(currentStep.current).index;

// console.log('GOAL', goalIndex, 'CURRENT', currIndex);

// If the goal is behind then just go straight there
if (goalIndex < currIndex) {
// Update the current step
Expand Down
11 changes: 11 additions & 0 deletions stories/Multistep/Complex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ const Stepper = () => {
);
};

const MultistepState = () => {
const state = useMultistepState();

return (
<pre>
<code>{JSON.stringify(state, null, 2)}</code>
</pre>
);
};

const Basic = () => {
const [state, setState] = useState(0);
const multistepApiRef = useRef();
Expand Down Expand Up @@ -294,6 +304,7 @@ const Basic = () => {
<Color />
<Dog />
</div>
{/* <MultistepState /> */}
</Multistep>
</div>
<div>
Expand Down

0 comments on commit 1fd1038

Please sign in to comment.