♻️(react) make className standard across components

The className prop was sometimes set onto the nested element and
sometimes on the container element, which was not consistent. Now
we always set the className onto the upmost element.
This commit is contained in:
Nathan Vasse
2024-03-04 15:21:09 +01:00
committed by NathanVss
parent f398e51db3
commit 20f5bb703b
23 changed files with 188 additions and 17 deletions

View File

@@ -191,4 +191,12 @@ describe("<TextArea/>", () => {
await user.clear(textarea);
screen.getByText("Value: .");
});
it("renders with className", async () => {
render(<TextArea className="my-custom-class" />);
screen.debug();
expect(
document.querySelector(".c__field--textarea.my-custom-class"),
).toBeInTheDocument();
});
});

View File

@@ -44,12 +44,13 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
setValue(props.value || "");
}, [props.value]);
const { fullWidth, rightText, text, textItems, ...areaProps } = props;
const { fullWidth, rightText, text, textItems, className, ...areaProps } =
props;
return (
<Field
{...props}
className="c__field--textarea"
className={classNames("c__field--textarea", className)}
rightText={rightTextToUse}
>
{/* We disabled linting for this specific line because we consider that the onClick props is only used for */}