Skip to content

Commit 956da96

Browse files
committed
Fixed custom key not displayed in JSON Schema form
1 parent 683b9fd commit 956da96

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Unreleased
44

5+
* Fixed custom key not displayed in JSON Schema form (\#529);
56
* Added dropdown for Python version in tasks (\#526);
67
* Improved formatting of errors in standard error alert component (\#526);
78
* Used `postgres-psycopg` adapter in CI (\#525);

jschema/__tests__/properties/object.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,30 @@ describe('Object properties', () => {
242242
expect(screen.getByRole('textbox', { name: 'key1' })).toHaveValue('foo');
243243
expect(screen.getByRole('textbox', { name: 'key2' })).toHaveValue('');
244244
});
245+
246+
it('Display object with custom key and title - key prevails over title', async function () {
247+
const { component } = renderSchema(
248+
{
249+
type: 'object',
250+
properties: {
251+
map: {
252+
type: 'object',
253+
additionalProperties: {
254+
type: 'object',
255+
title: 'PropertyTitle',
256+
properties: {
257+
test: {
258+
type: 'string'
259+
}
260+
}
261+
}
262+
}
263+
}
264+
},
265+
{ map: { k1: { test: 'foo' } } }
266+
);
267+
expect(component.getArguments()).deep.eq({ map: { k1: { test: 'foo' } } });
268+
expect(screen.queryByText('PropertyTitle')).toBeNull();
269+
expect(screen.queryByText('k1')).not.toBeNull();
270+
});
245271
});

jschema/src/lib/components/form_manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export class FormManager {
328328
manager: this,
329329
id: this.getUniqueId(),
330330
type: property.type || null,
331-
title: property.title || key || '',
331+
title: key && removable ? key : property.title || key || '',
332332
description: property.description || '',
333333
property: deepCopy(property),
334334
notifyChange: this.notifyChange

0 commit comments

Comments
 (0)