Skip to content

Commit

Permalink
Merge pull request #1480 from SenseNet/Fix-Short-TextField
Browse files Browse the repository at this point in the history
Short text field no value fix
  • Loading branch information
hassanad94 authored Mar 11, 2023
2 parents 1be71c2 + 425a056 commit 8b20056
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
4 changes: 3 additions & 1 deletion packages/sn-controls-react/src/fieldcontrols/short-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export const ShortText: React.FC<ReactClientFieldSetting<ShortTextFieldSetting>>
</Typography>
<Typography variant="body1" gutterBottom={true}>
{/* Temporary hot fix */}
{typeof props.fieldValue !== 'string' ? '[OBJECT]' : props.fieldValue || localization.noValue}
{typeof props.fieldValue === 'object' && props.fieldValue !== null
? '[OBJECT]'
: props.fieldValue || localization.noValue}
</Typography>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Short text field control in browse view should show [OBJECT] when iccorect type passed 1`] = `
<div>
<WithStyles(ForwardRef(Typography))
gutterBottom={true}
variant="caption"
>
Display name
</WithStyles(ForwardRef(Typography))>
<WithStyles(ForwardRef(Typography))
gutterBottom={true}
variant="body1"
>
[OBJECT]
</WithStyles(ForwardRef(Typography))>
</div>
`;

exports[`Short text field control in browse view should show the displayname and fieldValue when fieldValue is provided 1`] = `
<div>
<WithStyles(ForwardRef(Typography))
Expand Down
3 changes: 1 addition & 2 deletions packages/sn-controls-react/test/short-text.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ describe('Short text field control', () => {
const wrapper = shallow(<ShortText actionName="browse" settings={defaultSettings} />)
expect(wrapper.find(Typography).last().text()).toBe(defaultLocalization.shortText.noValue)
})
it('should show [OBJECT] when iccorect type passed', () => {
it('should show [OBJECT] when iccorect value type passed', () => {
const value = { url: '' }
const wrapper = shallow(<ShortText fieldValue={value as any} actionName="browse" settings={defaultSettings} />)
expect(wrapper.find(Typography).first().text()).toBe(defaultSettings.DisplayName)
expect(wrapper.find(Typography).last().text()).toBe('[OBJECT]')
expect(wrapper).toMatchSnapshot()
})
})
describe('in edit/new view', () => {
Expand Down

0 comments on commit 8b20056

Please sign in to comment.