Skip to content

Commit

Permalink
fix(Wizard): allow dynamic step update (#10766)
Browse files Browse the repository at this point in the history
* fix(Wizard): allow dynamic step update

* lock bug
  • Loading branch information
kmcfaul authored Jul 17, 2024
1 parent d235cd8 commit 8932cdc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/react-core/src/components/Wizard/Wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export const Wizard = ({
}
}, [startIndex]);

// When children change, active step index should reset
React.useEffect(() => {
setActiveStepIndex(startIndex);
}, [children, startIndex]);

const focusMainContentElement = () =>
setTimeout(() => {
wrapperRef?.current?.focus && wrapperRef.current.focus();
Expand Down
5 changes: 5 additions & 0 deletions packages/react-core/src/components/Wizard/WizardContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
const [currentSteps, setCurrentSteps] = React.useState<WizardStepType[]>(initialSteps);
const [currentFooter, setCurrentFooter] = React.useState<WizardFooterType>();

// Callback to update steps if they change after initial render
React.useEffect(() => {
setCurrentSteps(initialSteps);
}, [initialSteps]);

// Combined initial and current state steps
const steps = React.useMemo(
() =>
Expand Down

0 comments on commit 8932cdc

Please sign in to comment.