Skip to content

Commit aeaf892

Browse files
committed
Added console warning
1 parent c8a8f74 commit aeaf892

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

packages/react-core/src/components/Wizard/Wizard.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
6161
shouldFocusContent?: boolean;
6262
/** Adds plain styling to the wizard. */
6363
isPlain?: boolean;
64-
/** @beta Prevents the wizard from automatically applying plain styling when glass theme is enabled. */
64+
/** @beta Prevents the wizard from automatically applying plain styling when glass theme is enabled. When both this and isPlain are true, isPlain takes precedence. */
6565
isNoPlainOnGlass?: boolean;
6666
}
6767

@@ -85,6 +85,13 @@ export const Wizard = ({
8585
isNoPlainOnGlass = false,
8686
...wrapperProps
8787
}: WizardProps) => {
88+
if (isPlain && isNoPlainOnGlass) {
89+
// eslint-disable-next-line no-console
90+
console.warn(
91+
`Wizard: When both isPlain and isNoPlainOnGlass are true, isPlain will take precedence and isNoPlainOnGlass will have no effect. It's recommended to pass only one prop according to the current theme.`
92+
);
93+
}
94+
8895
const [activeStepIndex, setActiveStepIndex] = useState(startIndex);
8996
const initialSteps = buildSteps(children);
9097
const firstStepRef = useRef(initialSteps[startIndex - 1]);

packages/react-core/src/components/Wizard/__tests__/Wizard.test.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,41 @@ test(`Renders with ${styles.modifiers.noPlainOnGlass} class when isNoPlainOnGlas
687687

688688
expect(screen.getByTestId('wizard-no-plain')).toHaveClass(styles.modifiers.noPlainOnGlass);
689689
});
690+
691+
test('Does not log a warning when only isPlain is passed', () => {
692+
const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
693+
694+
render(
695+
<Wizard isPlain>
696+
<WizardStep id="test-step" name="Test step" />
697+
</Wizard>
698+
);
699+
700+
expect(consoleWarning).not.toHaveBeenCalled();
701+
});
702+
703+
test('Does not log a warning when only isNoPlainOnGlass is passed', () => {
704+
const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
705+
706+
render(
707+
<Wizard isNoPlainOnGlass>
708+
<WizardStep id="test-step" name="Test step" />
709+
</Wizard>
710+
);
711+
712+
expect(consoleWarning).not.toHaveBeenCalled();
713+
});
714+
715+
test('Logs a warning when both isPlain and isNoPlainOnGlass are passed', () => {
716+
const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
717+
718+
render(
719+
<Wizard isPlain isNoPlainOnGlass>
720+
<WizardStep id="test-step" name="Test step" />
721+
</Wizard>
722+
);
723+
724+
expect(consoleWarning).toHaveBeenCalledWith(
725+
`Wizard: When both isPlain and isNoPlainOnGlass are true, isPlain will take precedence and isNoPlainOnGlass will have no effect. It's recommended to pass only one prop according to the current theme.`
726+
);
727+
});

0 commit comments

Comments
 (0)