Skip to content

Commit 8b20056

Browse files
authored
Merge pull request #1480 from SenseNet/Fix-Short-TextField
Short text field no value fix
2 parents 1be71c2 + 425a056 commit 8b20056

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

packages/sn-controls-react/src/fieldcontrols/short-text.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export const ShortText: React.FC<ReactClientFieldSetting<ShortTextFieldSetting>>
5959
</Typography>
6060
<Typography variant="body1" gutterBottom={true}>
6161
{/* Temporary hot fix */}
62-
{typeof props.fieldValue !== 'string' ? '[OBJECT]' : props.fieldValue || localization.noValue}
62+
{typeof props.fieldValue === 'object' && props.fieldValue !== null
63+
? '[OBJECT]'
64+
: props.fieldValue || localization.noValue}
6365
</Typography>
6466
</div>
6567
)

packages/sn-controls-react/test/__snapshots__/short-text.test.tsx.snap

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Short text field control in browse view should show [OBJECT] when iccorect type passed 1`] = `
4-
<div>
5-
<WithStyles(ForwardRef(Typography))
6-
gutterBottom={true}
7-
variant="caption"
8-
>
9-
Display name
10-
</WithStyles(ForwardRef(Typography))>
11-
<WithStyles(ForwardRef(Typography))
12-
gutterBottom={true}
13-
variant="body1"
14-
>
15-
[OBJECT]
16-
</WithStyles(ForwardRef(Typography))>
17-
</div>
18-
`;
19-
203
exports[`Short text field control in browse view should show the displayname and fieldValue when fieldValue is provided 1`] = `
214
<div>
225
<WithStyles(ForwardRef(Typography))

packages/sn-controls-react/test/short-text.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ describe('Short text field control', () => {
2424
const wrapper = shallow(<ShortText actionName="browse" settings={defaultSettings} />)
2525
expect(wrapper.find(Typography).last().text()).toBe(defaultLocalization.shortText.noValue)
2626
})
27-
it('should show [OBJECT] when iccorect type passed', () => {
27+
it('should show [OBJECT] when iccorect value type passed', () => {
2828
const value = { url: '' }
2929
const wrapper = shallow(<ShortText fieldValue={value as any} actionName="browse" settings={defaultSettings} />)
3030
expect(wrapper.find(Typography).first().text()).toBe(defaultSettings.DisplayName)
3131
expect(wrapper.find(Typography).last().text()).toBe('[OBJECT]')
32-
expect(wrapper).toMatchSnapshot()
3332
})
3433
})
3534
describe('in edit/new view', () => {

0 commit comments

Comments
 (0)