@@ -20,19 +20,21 @@ const memoValues = (initialValue) => {
2020} ;
2121
2222const WizardNavigationInternal = React . memo (
23- ( { navSchema, activeStepIndex, maxStepIndex, jumpToStep, formOptions : { valid } } ) =>
23+ ( { navSchema, activeStepIndex, maxStepIndex, jumpToStep, valid, validating } ) =>
2424 navSchema
2525 . filter ( ( field ) => field . primary )
2626 . map ( ( step ) => {
2727 const substeps = step . substepOf && navSchema . filter ( ( field ) => field . substepOf === step . substepOf ) ;
2828
29+ const isValid = valid && ! validating ;
30+
2931 return (
3032 < WizardNavItem
3133 key = { step . substepOf || step . title }
3234 text = { step . substepOf || step . title }
3335 isCurrent = { substeps ? activeStepIndex >= step . index && activeStepIndex < step . index + substeps . length : activeStepIndex === step . index }
34- isDisabled = { valid ? maxStepIndex < step . index : step . index > activeStepIndex }
35- onNavItemClick = { ( ind ) => jumpToStep ( ind , valid ) }
36+ isDisabled = { isValid ? maxStepIndex < step . index : step . index > activeStepIndex }
37+ onNavItemClick = { ( ind ) => jumpToStep ( ind , isValid ) }
3638 step = { step . index }
3739 >
3840 { substeps && (
@@ -42,8 +44,8 @@ const WizardNavigationInternal = React.memo(
4244 key = { substep . title }
4345 text = { substep . title }
4446 isCurrent = { activeStepIndex === substep . index }
45- isDisabled = { valid ? maxStepIndex < substep . index : substep . index > activeStepIndex }
46- onNavItemClick = { ( ind ) => jumpToStep ( ind , valid ) }
47+ isDisabled = { isValid ? maxStepIndex < substep . index : substep . index > activeStepIndex }
48+ onNavItemClick = { ( ind ) => jumpToStep ( ind , isValid ) }
4749 step = { substep . index }
4850 />
4951 ) ) }
@@ -60,12 +62,11 @@ WizardNavigationInternal.propTypes = {
6062 maxStepIndex : PropTypes . number . isRequired ,
6163 jumpToStep : PropTypes . func . isRequired ,
6264 navSchema : PropTypes . array . isRequired ,
63- formOptions : PropTypes . shape ( {
64- valid : PropTypes . bool . isRequired
65- } ) . isRequired
65+ valid : PropTypes . bool . isRequired ,
66+ validating : PropTypes . bool . isRequired
6667} ;
6768
68- const WizardNavigation = ( { activeStepIndex , maxStepIndex , jumpToStep , navSchema , formOptions , setPrevSteps, crossroads, values } ) => {
69+ const WizardNavigation = ( { setPrevSteps, crossroads, values, ... props } ) => {
6970 const [ memoValue ] = useState ( ( ) =>
7071 memoValues (
7172 crossroads
@@ -96,26 +97,13 @@ const WizardNavigation = ({ activeStepIndex, maxStepIndex, jumpToStep, navSchema
9697 }
9798 } ) ;
9899
99- return (
100- < WizardNavigationInternal
101- navSchema = { navSchema }
102- activeStepIndex = { activeStepIndex }
103- maxStepIndex = { maxStepIndex }
104- jumpToStep = { jumpToStep }
105- formOptions = { formOptions }
106- />
107- ) ;
100+ return < WizardNavigationInternal { ...props } /> ;
108101} ;
109102
110103WizardNavigation . propTypes = {
111- activeStepIndex : PropTypes . number . isRequired ,
112- maxStepIndex : PropTypes . number . isRequired ,
113- jumpToStep : PropTypes . func . isRequired ,
114104 setPrevSteps : PropTypes . func . isRequired ,
115- navSchema : PropTypes . array . isRequired ,
116105 values : PropTypes . object . isRequired ,
117- crossroads : PropTypes . arrayOf ( PropTypes . string ) ,
118- formOptions : PropTypes . object . isRequired
106+ crossroads : PropTypes . arrayOf ( PropTypes . string )
119107} ;
120108
121109export default WizardNavigation ;
0 commit comments