diff --git a/.changeset/swift-shoes-tell.md b/.changeset/swift-shoes-tell.md
new file mode 100644
index 0000000..7ed0eb4
--- /dev/null
+++ b/.changeset/swift-shoes-tell.md
@@ -0,0 +1,5 @@
+---
+"@openfun/cunningham-react": minor
+---
+
+add clearable option to Select
diff --git a/packages/react/src/components/Forms/Select/index.mdx b/packages/react/src/components/Forms/Select/index.mdx
index e84a44e..a3519db 100644
--- a/packages/react/src/components/Forms/Select/index.mdx
+++ b/packages/react/src/components/Forms/Select/index.mdx
@@ -75,6 +75,14 @@ By default, the select has a default width, like all inputs. But you can force i
+## Clearable
+
+By default, the select is clearable ( the cross icon on the right is shown ). You can disable it by using the `clearable` props.
+
+
+
## Controlled / Non Controlled
Like a native select, you can use the Select component in a controlled or non controlled way. You can see the example below
diff --git a/packages/react/src/components/Forms/Select/index.spec.tsx b/packages/react/src/components/Forms/Select/index.spec.tsx
index 5c592d6..f18f1e3 100644
--- a/packages/react/src/components/Forms/Select/index.spec.tsx
+++ b/packages/react/src/components/Forms/Select/index.spec.tsx
@@ -1028,5 +1028,44 @@ describe("", () => {
city: null,
});
});
+
+ it("should not be clearable", async () => {
+ render(
+
+
+
+ );
+ screen.getByRole("combobox", {
+ name: "City",
+ });
+ const valueRendered = document.querySelector(".c__select__inner__value");
+
+ // Make sure default value is rendered.
+ expect(valueRendered).toHaveTextContent("Paris");
+ // Make sure the clear button is not rendered.
+ expect(
+ screen.queryByRole("button", {
+ name: "Clear selection",
+ })
+ ).not.toBeInTheDocument();
+ });
});
});
diff --git a/packages/react/src/components/Forms/Select/index.tsx b/packages/react/src/components/Forms/Select/index.tsx
index f3d8cc8..473bfbd 100644
--- a/packages/react/src/components/Forms/Select/index.tsx
+++ b/packages/react/src/components/Forms/Select/index.tsx
@@ -34,6 +34,7 @@ type Props = PropsWithChildren &
target: { value: string | number | undefined };
}) => void;
disabled?: boolean;
+ clearable?: boolean;
};
function getOptionsFilter(inputValue?: string) {
@@ -96,6 +97,7 @@ const SelectAux = ({
downshiftReturn,
value,
disabled,
+ clearable = true,
}: SelectAuxProps) => {
const { t } = useCunningham();
const labelProps = downshiftReturn.getLabelProps();
@@ -148,7 +150,7 @@ const SelectAux = ({