Skip to content

Commit 85f2bf3

Browse files
authored
fix: <Select disabled> for type: string + enum schemas (#5601)
* fix: pass `disabled` through JsonSchemaForm – JsonSchema_string – Select * migrate 5452 regression test
1 parent f523ec4 commit 85f2bf3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/core/json-schema-components.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class JsonSchema_string extends Component {
7878
allowedValues={ enumValue }
7979
value={ value }
8080
allowEmptyValue={ !required }
81+
disabled={disabled}
8182
onChange={ this.onEnumChange }/>)
8283
}
8384

test/e2e-cypress/tests/bugs/5452.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ describe("#5452: <Select /> crashing in Parameters", function() {
88
cy.visit("http://localhost:3230/?url=/documents/bugs/5452/openapi.yaml")
99
.get("#operations-default-get_endpoint")
1010
.click()
11+
.get(".try-out__btn")
12+
.click()
1113
.get(".parameters > tbody > tr > .parameters-col_description > select")
1214
.select("")
1315
.get(".parameters > tbody > tr > .parameters-col_description > select")
@@ -22,6 +24,8 @@ describe("#5452: <Select /> crashing in Parameters", function() {
2224
cy.visit("http://localhost:3230/?url=/documents/bugs/5452/swagger.yaml")
2325
.get("#operations-default-get_endpoint")
2426
.click()
27+
.get(".try-out__btn")
28+
.click()
2529
.get(".parameters > tbody > tr > .parameters-col_description > select")
2630
.select("")
2731
.get(".parameters > tbody > tr > .parameters-col_description > select")

test/mocha/components/json-schema-form.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ describe("<JsonSchemaForm/>", function(){
4040
expect(wrapper.find("select option").eq(2).text()).toEqual("two")
4141
})
4242

43+
it("should render a string enum as disabled when JsonSchemaForm is disabled", function(){
44+
45+
let props = {
46+
getComponent: getComponentStub,
47+
value: "",
48+
onChange: () => {},
49+
keyName: "",
50+
fn: {},
51+
schema: {
52+
type: "string",
53+
enum: ["one", "two"]
54+
},
55+
disabled: true
56+
}
57+
58+
let wrapper = render(<JsonSchemaForm {...props}/>)
59+
60+
expect(wrapper.find("select").attr("disabled")).toEqual("disabled")
61+
})
62+
63+
4364
it("should render the correct options for a required string enum parameter", function(){
4465

4566
let props = {

0 commit comments

Comments
 (0)