From 81b2e54b40b212dd9fdd7211e1d57bd6ced3c176 Mon Sep 17 00:00:00 2001 From: Regourd Colin Date: Mon, 7 Oct 2024 12:04:11 +0200 Subject: [PATCH] Nullable realtionship (#473) --- .changeset/wise-snakes-boil.md | 5 +++++ packages/next-admin/src/components/inputs/SelectWidget.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/wise-snakes-boil.md diff --git a/.changeset/wise-snakes-boil.md b/.changeset/wise-snakes-boil.md new file mode 100644 index 00000000..88b42a31 --- /dev/null +++ b/.changeset/wise-snakes-boil.md @@ -0,0 +1,5 @@ +--- +"@premieroctet/next-admin": patch +--- + +Fix relation one-to-many - nullable relation diff --git a/packages/next-admin/src/components/inputs/SelectWidget.tsx b/packages/next-admin/src/components/inputs/SelectWidget.tsx index 5c57b740..e86747a7 100644 --- a/packages/next-admin/src/components/inputs/SelectWidget.tsx +++ b/packages/next-admin/src/components/inputs/SelectWidget.tsx @@ -36,7 +36,7 @@ const SelectWidget = ({ const { basePath } = useConfig(); - const handleChange = (option: Enumeration) => { + const handleChange = (option: Enumeration | null) => { setFieldDirty(props.name); onChange(option); onClose(); @@ -95,7 +95,7 @@ const SelectWidget = ({ className="flex items-center" onClick={(e) => { e.preventDefault(); - onChange({}); + handleChange(null); }} >