♻️(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

@@ -1448,4 +1448,15 @@ describe("<DatePicker/>", () => {
// Make sure value is selected, with the same time as the initial value.
screen.getByText(`Value = 2023-04-12T12:00:00.000Z|`);
});
it("renders with className", async () => {
render(
<CunninghamProvider>
<DatePicker label="Date" className="my-custom-class" />
</CunninghamProvider>,
);
expect(
document.querySelector(".c__field.my-custom-class"),
).toBeInTheDocument();
});
});

View File

@@ -57,6 +57,7 @@ export type DatePickerAuxProps = PropsWithChildren &
const DatePickerAux = forwardRef(
(
{
className,
pickerState,
pickerProps,
onClear,
@@ -86,7 +87,7 @@ const DatePickerAux = forwardRef(
<I18nProvider locale={locale || currentLocale}>
<Field
{...props}
className={classNames({
className={classNames(className, {
"c__date-picker__range__container": isRange,
})}
>

View File

@@ -1175,4 +1175,18 @@ describe("<DateRangePicker/>", () => {
datepickerEnd: "",
});
});
it("renders with className", async () => {
render(
<CunninghamProvider>
<DateRangePicker
startLabel="Start"
endLabel="End"
className="my-custom-class"
/>
</CunninghamProvider>,
);
expect(
document.querySelector(".c__field.my-custom-class"),
).toBeInTheDocument();
});
});