Skip to content

Commit 37f3e61

Browse files
committed
fixup! fix(core): field ui-options higher priority
1 parent 6bdc3a4 commit 37f3e61

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

packages/core/test/SchemaField.test.jsx

-26
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,6 @@ describe('SchemaField', () => {
8888
globalUiOptions: { copyable: true },
8989
});
9090
});
91-
it('should provide expected registry with field option first', () => {
92-
let receivedProps;
93-
const schema = {
94-
type: 'object',
95-
properties: {
96-
a: { type: 'string' },
97-
},
98-
};
99-
100-
createFormComponent({
101-
schema,
102-
uiSchema: {
103-
'ui:globalOptions': { readonly: true },
104-
a: {
105-
'ui:readonly': false,
106-
'ui:widget': (props) => {
107-
receivedProps = props;
108-
return null;
109-
},
110-
},
111-
},
112-
});
113-
114-
const { readonly } = receivedProps;
115-
expect(readonly).eql(false);
116-
});
11791
});
11892

11993
describe('Unsupported field', () => {

packages/core/test/uiSchema.test.jsx

+32-6
Original file line numberDiff line numberDiff line change
@@ -2505,9 +2505,7 @@ describe('uiSchema', () => {
25052505
});
25062506

25072507
describe('ObjectField', () => {
2508-
let node;
2509-
2510-
beforeEach(() => {
2508+
it('should mark as readonly an ObjectField', () => {
25112509
const schema = {
25122510
type: 'object',
25132511
properties: {
@@ -2523,13 +2521,41 @@ describe('uiSchema', () => {
25232521
const uiSchema = {};
25242522

25252523
let rendered = createFormComponent({ schema, uiSchema });
2526-
node = rendered.node;
2527-
});
2524+
const node = rendered.node;
25282525

2529-
it('should mark as readonly an ObjectField', () => {
25302526
const disabled = [].map.call(node.querySelectorAll('[type=text]'), (node) => node.hasAttribute('readonly'));
25312527
expect(disabled).eql([true, true]);
25322528
});
2529+
2530+
it('should not mark as readonly even if globalOptions set readonly', () => {
2531+
const schema = {
2532+
type: 'object',
2533+
properties: {
2534+
foo: {
2535+
type: 'string',
2536+
},
2537+
bar: {
2538+
type: 'string',
2539+
},
2540+
},
2541+
readOnly: true,
2542+
};
2543+
2544+
const uiSchema = {
2545+
'ui:globalOptions': {
2546+
readonly: true,
2547+
},
2548+
foo: {
2549+
'ui:readonly': false,
2550+
},
2551+
};
2552+
2553+
let rendered = createFormComponent({ schema, uiSchema });
2554+
const node = rendered.node;
2555+
2556+
const disabled = [].map.call(node.querySelectorAll('[type=text]'), (node) => node.hasAttribute('readonly'));
2557+
expect(disabled).eql([false, true]);
2558+
});
25332559
});
25342560
});
25352561

0 commit comments

Comments
 (0)