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:
Ashwin Ramaswami
2019-12-23 17:01:55 +05:30
committed by GitHub
parent 71949f06bf
commit 53ee91f95d
3 changed files with 6 additions and 1 deletions

View File

@@ -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}

View File

@@ -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", () => {

View File

@@ -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", () => {