Skip to content

Commit

Permalink
Merge branch 'master' into create-button-title
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored May 7, 2021
2 parents 8bd21e0 + 400d882 commit 1a072e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-buckets-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/fields': patch
---

Fixed Admin UI issues when using `select` fields with `dataType: 'integer'`.
9 changes: 7 additions & 2 deletions packages-next/fields/src/types/select/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 (
Expand Down Expand Up @@ -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 };
},
Expand Down

0 comments on commit 1a072e1

Please sign in to comment.