Skip to content

Commit

Permalink
Fix text, integer, float and decimal on the item view when us…
Browse files Browse the repository at this point in the history
…ing `ui.itemView.fieldMode: 'read'`. (#6758)
  • Loading branch information
emmatown authored Oct 11, 2021
1 parent 1285f54 commit f38772b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-beds-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': patch
---

Fixed `text`, `integer`, `float` and `decimal` on the item view when using `ui.itemView.fieldMode: 'read'`.
4 changes: 2 additions & 2 deletions examples-staging/basic/admin/fieldViews/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const Field = ({ field, value, onChange, autoFocus }: FieldProps<typeof c
value={value.inner.kind === 'null' ? '' : value.inner.value}
/>
)
) : (
value
) : value.inner.kind === 'null' ? null : (
value.inner.value
)}
</FieldContainer>
);
6 changes: 5 additions & 1 deletion packages/keystone/src/fields/types/decimal/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export const Field = ({
return (
<FieldContainer>
<FieldLabel htmlFor={field.path}>{field.label}</FieldLabel>
{onChange ? <TextInput id={field.path} autoFocus={autoFocus} {...inputProps} /> : value}
{onChange ? (
<TextInput id={field.path} autoFocus={autoFocus} {...inputProps} />
) : (
value.value?.toString()
)}
{(hasBlurred || forceValidation) && validationMessage && (
<span css={{ color: 'red' }}>{validationMessage}</span>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/keystone/src/fields/types/float/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const Field = ({
/>
</span>
) : (
value
value.value
)}
</FieldContainer>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/keystone/src/fields/types/integer/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const Field = ({
/>
</span>
) : (
value
value.value
)}
</FieldContainer>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/keystone/src/fields/types/text/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export const Field = ({
</span>
))}
</Stack>
) : (
value
) : value.inner.kind === 'null' ? null : (
value.inner.value
)}
</FieldContainer>
);
Expand Down

0 comments on commit f38772b

Please sign in to comment.