Skip to content

Commit

Permalink
Fix for issue josdejong#1111 (josdejong#1116)
Browse files Browse the repository at this point in the history
Fixes enum dropdown not showing when using patternProperties for schema.

The issue happens as `_findSchema` is recursively called one more than than it should. Instead of returning the nested schema object (eg. `{ enum: [1, 2, 3] }`), it returns the parent object, eg.:

```javascript
{
  type: 'object',
  properties: {
    testrigId: {
      enum: [1, 2, 3]
    },
  },
  required: [
    'testrigId'
  ]
}
```

The fix adds an if check to ignore the additional recursive call and return the correct object.

The unit tests pass and I've also tested a complex schema inside `patternProperties` that uses the special types (boolean, color, enum).
  • Loading branch information
ziga-miklic authored Sep 23, 2020
1 parent 41fbf69 commit 6cf627a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4448,7 +4448,7 @@ Node._findSchema = (schema, schemaRefs, path) => {

if (typeof key === 'string' && childSchema.patternProperties && !(childSchema.properties && key in childSchema.properties)) {
for (const prop in childSchema.patternProperties) {
if (key.match(prop)) {
if (key.match(prop) && (foundSchema.properties || foundSchema.patternProperties)) {
foundSchema = Node._findSchema(childSchema.patternProperties[prop], schemaRefs, nextPath)
}
}
Expand Down

0 comments on commit 6cf627a

Please sign in to comment.