Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/react-core/src/components/Wizard/Wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export class Wizard extends React.Component<WizardProps, WizardState> {
return (
<WizardNavItem
key={index}
id={step.id}
content={step.name}
isExpandable={isNavExpandable}
isCurrent={hasActiveChild}
Expand All @@ -399,6 +400,7 @@ export class Wizard extends React.Component<WizardProps, WizardState> {
return (
<WizardNavItem
key={`child_${indexChild}`}
id={childStep.id}
content={childStep.name}
isCurrent={activeStep.name === childStep.name}
isDisabled={!enabled}
Expand All @@ -417,6 +419,7 @@ export class Wizard extends React.Component<WizardProps, WizardState> {
<WizardNavItem
{...step.stepNavItemProps}
key={index}
id={step.id}
content={step.name}
isCurrent={activeStep.name === step.name}
isDisabled={!enabled}
Expand Down
4 changes: 4 additions & 0 deletions packages/react-core/src/components/Wizard/WizardNavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface WizardNavItemProps {
href?: string;
/** Flag indicating that this NavItem has child steps and is expandable */
isExpandable?: boolean;
/** The id for the nav item */
id?: string | number;
}

export const WizardNavItem: React.FunctionComponent<WizardNavItemProps> = ({
Expand All @@ -34,6 +36,7 @@ export const WizardNavItem: React.FunctionComponent<WizardNavItemProps> = ({
navItemComponent = 'button',
href = null,
isExpandable = false,
id,
...rest
}: WizardNavItemProps) => {
const NavItemComponent = navItemComponent;
Expand Down Expand Up @@ -69,6 +72,7 @@ export const WizardNavItem: React.FunctionComponent<WizardNavItemProps> = ({
<NavItemComponent
{...rest}
{...(navItemComponent === 'a' ? { ...linkProps } : { ...btnProps })}
{...(id && { id: id.toString() })}
onClick={() => (isExpandable ? setIsExpanded(!isExpanded || isCurrent) : onNavItemClick(step))}
className={css(
styles.wizardNavLink,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ import { Wizard, WizardStepFunctionType, WizardStep } from '../Wizard';
describe('Wizard', () => {
test('Wizard should match snapshot', () => {
const steps: WizardStep[] = [
{ name: 'A', component: <p>Step 1</p> },
{ name: 'A', id: "step-A", component: <p>Step 1</p> },
{
name: 'B',
id: "step-B",
steps: [
{
name: 'B-1',
id: "step-B-1",
component: <p>Step 2</p>,
enableNext: true
},
{
name: 'B-2',
id: "step-B-2",
component: <p>Step 3</p>,
enableNext: false
}
]
},
{ name: 'C', component: <p>Step 4</p> },
{ name: 'D', component: <p>Step 5</p> }
{ name: 'C', id: "step-C", component: <p>Step 4</p> },
{ name: 'D', id: "step-D", component: <p>Step 5</p> }
];
const onBack: WizardStepFunctionType = step => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
<button
aria-current="step"
class="pf-c-wizard__nav-link pf-m-current"
id="step-A"
>
A
</button>
Expand All @@ -361,6 +362,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
<button
aria-current="false"
class="pf-c-wizard__nav-link"
id="step-B"
>
B
</button>
Expand All @@ -373,6 +375,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
<button
aria-current="false"
class="pf-c-wizard__nav-link"
id="step-B-1"
>
B-1
</button>
Expand All @@ -383,6 +386,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
<button
aria-current="false"
class="pf-c-wizard__nav-link"
id="step-B-2"
>
B-2
</button>
Expand All @@ -395,6 +399,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
<button
aria-current="false"
class="pf-c-wizard__nav-link"
id="step-C"
>
C
</button>
Expand All @@ -405,6 +410,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
<button
aria-current="false"
class="pf-c-wizard__nav-link"
id="step-D"
>
D
</button>
Expand Down