Skip to content

Commit

Permalink
fix(Wizard): allow dynamic step update (#10748)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcfaul authored Jul 16, 2024
1 parent c16c6f4 commit 9257008
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 @@ -91,6 +91,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 9257008

Please sign in to comment.