Skip to content

Commit

Permalink
Harmonize disabling wizard stepper buttons across all instances
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKniephoff committed Jun 4, 2024
1 parent 427072c commit 38be9eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/events/partials/wizards/NewEventWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const NewEventWizard: React.FC<{
steps={steps}
page={page}
setPage={setPage}
formik={formik}
completed={pageCompleted}
/>
<div>
Expand Down
7 changes: 6 additions & 1 deletion src/components/shared/wizard/WizardStepperEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {
useStepperStyle,
} from "../../../utils/wizardUtils";
import CustomStepIcon from "./CustomStepIcon";
import { FormikProps } from "formik";

const WizardStepperEvent = ({
steps,
page,
setPage,
formik,
completed,
} : {
steps: {
Expand All @@ -22,6 +24,7 @@ const WizardStepperEvent = ({
}[],
page: number,
setPage: (num: number) => void,
formik: FormikProps<any>,
completed: Record<number, boolean>,
}) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -50,6 +53,8 @@ const WizardStepperEvent = ({
}
};

const disabled = !(formik.dirty && formik.isValid);

return (
<Stepper
activeStep={page}
Expand All @@ -61,7 +66,7 @@ const WizardStepperEvent = ({
{steps.map((label, key) =>
label.hidden || (
<Step key={label.translation} completed={completed[key]}>
<StepButton onClick={() => handleOnClick(key)}>
<StepButton onClick={() => handleOnClick(key)} disabled={disabled}>
<StepLabel className={labelClasses.root} StepIconComponent={CustomStepIcon}>
{t(label.translation)}
</StepLabel>
Expand Down

0 comments on commit 38be9eb

Please sign in to comment.