Open yhafez opened 3 months ago
@yhafez are there any reproduction details I'm missing? There's this example on the docs site:
<Stepper>
<Step
status="complete"
tooltip={<><div>Step 1: Foo</div><div>Status: Complete</div></>}
tooltipText="Foo Complete"
/>
<Step
status="current"
tooltip={<><div>Step 2: Bar</div><div>Status: Current</div></>}
tooltipText="Bar Current"
/>
</Stepper>
But I'm not seeing any of the console output above, so I'm still trying to figure out how to reproduce.
@scurker it looks like the issue is when the Step
is rendered with this prop and tooltip
is undefined
. Here's my implementation:
<Stepper className={narrow ? styles.narrowStepper : undefined}>
{steps.map(({ header }, i) => {
const stepStatus = getStepStatus(currentStep, i);
const stepStatusCapitalized = getCapitalizedStepStatus(
t,
stepStatus
);
return (
<Step
status={stepStatus}
key={header}
tooltip={
narrow ? (
<>
<Trans>
<div>
Step {{ i: i + 1 }}: {{ header }}
</div>
<div>Status: {{ stepStatusCapitalized }}</div>
</Trans>
</>
) : undefined
}
tooltipText={
narrow
? `${header} ${getStepStatus(currentStep, i)}`
: undefined
}
>
{narrow ? null : `${header}`}
</Step>
);
})}
</Stepper>
narrow
come from the useMediaQuery
hook, but when I explicitly set it to true, the error doesn't appear. So even though tooltipText
is set to undefined
when tooltip
is set to undefined
(in the case where narrow
is false
), the console.error still appears in the console.
Not sure if we should explicitly handle when both are undefined
in Cauldron, or if we should leave it to the user to conditionally render a separate Step
component instead like so in my example:
<Stepper className={narrow ? styles.narrowStepper : undefined}>
{steps.map(({ header }, i) => {
const stepStatus = getStepStatus(currentStep, i);
const stepStatusCapitalized = getCapitalizedStepStatus(
t,
stepStatus
);
return narrow ? (
<Step
status={stepStatus}
key={header}
tooltip={
<>
<Trans>
<div>
Step {{ i: i + 1 }}: {{ header }}
</div>
<div>Status: {{ stepStatusCapitalized }}</div>
</Trans>
</>
}
tooltipText={`${header} ${getStepStatus(currentStep, i)}`}
/ >
) : (
<Step
status={stepStatus}
key={header}
>
{header}
</Step>
);
})}
</Stepper>
My inclination is that we should handle when they're both undefined
so the end user doesn't need to worry about it and since the user won't know they should use this pattern instead of the pattern I was originally using. Basically just not setting the tooltipText
prop when tooltip
is undefined. What do you think?
I'm trying to wrap my head around on how that error is generated. We do a sanity check for the tooltip
prop:
I guess we're spreading the props onto the li
element, but the prop itself should be undefined. It's an unusual use case since normally the props themselves aren't conditional.
Steps to reproduce
Steps to reproduce
1) Create a stepper component 2) Add a
tooltip
andtooltipText
attribute 3) Examine the devtools consoleExpected Behavior
No error
Actual Behavior
An error is shown in the console, though it doesn't show up in linting or compilation and does't break the app. An example of the error can be found under "Relevant log output"
Version
6.3.0
What browsers are you experiencing the problem on?
Chrome
Relevant log output
Anything else we should know?
Additional information