Skip to content

Commit 6d07a45

Browse files
authored
fix(input): avoid undefined input help text classname (#1265)
Signed-off-by: David Edler <[email protected]>
1 parent 302413d commit 6d07a45

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/components/Input/Input.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ describe("Input", () => {
114114

115115
it("can display help for a checkbox", async () => {
116116
const help = "Save me!";
117-
render(<Input help={help} type="checkbox" />);
117+
const { container } = render(<Input help={help} type="checkbox" />);
118118
expect(screen.getByRole("checkbox")).toHaveAccessibleDescription(help);
119+
expect(container.querySelector(".p-form-help-text")).not.toHaveClass(
120+
"undefined",
121+
);
119122
});
120123

121124
it("can add additional classes", () => {

src/components/Input/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type Props = PropsWithSpread<
3232
/**
3333
* Optional class(es) to pass to the help text element.
3434
*/
35-
helpClassName?: ReactNode;
35+
helpClassName?: string;
3636
/**
3737
* The id of the input.
3838
*/
@@ -160,7 +160,7 @@ const Input = ({
160160
error={error}
161161
forId={inputId}
162162
help={help}
163-
helpClassName={helpClassName + ""}
163+
helpClassName={helpClassName}
164164
helpId={helpId}
165165
isTickElement={type === "checkbox" || type === "radio"}
166166
label={fieldLabel}

0 commit comments

Comments
 (0)