diff --git a/.changeset/ninety-buckets-mate.md b/.changeset/ninety-buckets-mate.md new file mode 100644 index 00000000000..c4ebcb0d004 --- /dev/null +++ b/.changeset/ninety-buckets-mate.md @@ -0,0 +1,5 @@ +--- +'@keystone-next/fields': patch +--- + +Fixed Admin UI issues when using `select` fields with `dataType: 'integer'`. diff --git a/packages-next/fields/src/types/select/views/index.tsx b/packages-next/fields/src/types/select/views/index.tsx index db857225210..70dd35459aa 100644 --- a/packages-next/fields/src/types/select/views/index.tsx +++ b/packages-next/fields/src/types/select/views/index.tsx @@ -74,6 +74,11 @@ export const controller = ( label: x.label, value: x.value.toString(), })); + + // Transform from string value to dataType appropriate value + const t = (v: string | null) => + v === null ? null : config.fieldMeta.dataType === 'integer' ? parseInt(v) : v; + return { path: config.path, label: config.label, @@ -93,7 +98,7 @@ export const controller = ( } return null; }, - serialize: value => ({ [config.path]: value?.value ?? null }), + serialize: value => ({ [config.path]: t(value?.value ?? null) }), filter: { Filter(props) { return ( @@ -126,7 +131,7 @@ export const controller = ( key = `${config.path}_not`; } - const value = isMulti ? options.map(x => x.value) : options[0].value; + const value = isMulti ? options.map(x => t(x.value)) : t(options[0].value); return { [key]: value }; },