Skip to content

Commit

Permalink
Fix unique key issue in WizzardStepper
Browse files Browse the repository at this point in the history
Fixes a web console complaint about missing unique keys in the
WizzardSteppers. I deem using .filter() a nicer solution than a ternary
operator that checks if the hidden property of the current label object
is false and rendering an empty fragment. This is probably also what
made the console unhappy.

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
  • Loading branch information
ziegenberg committed May 21, 2024
1 parent 34dd129 commit 41acd80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions app/src/components/shared/wizard/WizardStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ const WizardStepper = ({
connector={false}
className={cn("step-by-step", classes.root)}
>
{steps.map((label, key) =>
!label.hidden ? (
{steps.filter(step => !step.hidden).map((label, key) => (
<Step key={label.translation} completed={completed[key]}>
<StepButton onClick={() => handleOnClick(key)} disabled={disabled}>
<StepLabel StepIconComponent={CustomStepIcon}>
{t(label.translation)}
</StepLabel>
</StepButton>
</Step>
) : <></>
)}
))}
</Stepper>
);
};
Expand Down
6 changes: 2 additions & 4 deletions app/src/components/shared/wizard/WizardStepperEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,15 @@ const WizardStepperEvent = ({
connector={false}
className={cn("step-by-step", classes.root)}
>
{steps.map((label, key) =>
!label.hidden ? (
{steps.filter(step => !step.hidden).map((label, key) => (
<Step key={label.translation} completed={completed[key]}>
<StepButton onClick={() => handleOnClick(key)}>
<StepLabel StepIconComponent={CustomStepIcon}>
{t(label.translation)}
</StepLabel>
</StepButton>
</Step>
) : <></>
)}
))}
</Stepper>
);
};
Expand Down

0 comments on commit 41acd80

Please sign in to comment.