mirror of
https://github.com/zhigang1992/react-jsonschema-form.git
synced 2026-01-12 09:23:40 +08:00
Fix id of anyof select (#1212)
* fix: fix id of anyof select * test: add tests for oneof and anyof ids * test fix: change oneof to anyof in test * properly use __anyof_select or __oneof_select based on schema * prettier
This commit is contained in:
@@ -111,6 +111,7 @@ class AnyOfField extends Component {
|
||||
options,
|
||||
registry,
|
||||
uiSchema,
|
||||
schema,
|
||||
} = this.props;
|
||||
|
||||
const _SchemaField = registry.fields.SchemaField;
|
||||
@@ -139,7 +140,9 @@ class AnyOfField extends Component {
|
||||
<div className="panel panel-default panel-body">
|
||||
<div className="form-group">
|
||||
<Widget
|
||||
id={`${idSchema.$id}_anyof_select`}
|
||||
id={`${idSchema.$id}${
|
||||
schema.oneOf ? "__oneof_select" : "__anyof_select"
|
||||
}`}
|
||||
schema={{ type: "number", default: 0 }}
|
||||
onChange={this.onOptionChange}
|
||||
onBlur={onBlur}
|
||||
|
||||
@@ -53,6 +53,7 @@ describe("anyOf", () => {
|
||||
});
|
||||
|
||||
expect(node.querySelectorAll("select")).to.have.length.of(1);
|
||||
expect(node.querySelector("select").id).eql("root__anyof_select");
|
||||
});
|
||||
|
||||
it("should assign a default value and set defaults on option change", () => {
|
||||
|
||||
@@ -53,6 +53,7 @@ describe("oneOf", () => {
|
||||
});
|
||||
|
||||
expect(node.querySelectorAll("select")).to.have.length.of(1);
|
||||
expect(node.querySelector("select").id).eql("root__oneof_select");
|
||||
});
|
||||
|
||||
it("should assign a default value and set defaults on option change", () => {
|
||||
|
||||
Reference in New Issue
Block a user