Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/context/json_schema_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class JSONSchemaFormDataProvider extends ContextProvider {
const schema = this.uiSchema;
return _.each(schema, (v, k, l) => {
l[k] = { ...v, ...this.defaultFieldStyles };
// retain any prior class attributes
l[k].classNames = `${v.classNames} ${this.defaultClassNames}`;
l[k].classNames = `${v.classNames || ""} ${this.defaultClassNames || ""}`;
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happened here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, it would add undefined to the default class name if the UI schema did not have a classNames property for the given field. I just changed the logic to only add classNames to the string if it is actually defined.

While working on this, I found the behavior of this function a bit counterintuitive, and perhaps we want to consider changing it so that whenever classNames is present in the UI schema, it overwrites rather than prepends the default class names.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The above could be done with just:
l[k].classNames = `${v.classNames || ''} ${this.defaultClassNames || ''}`;
  1. It seems that you changes the logic for ...this.defaultFieldStyles also - is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding 2, defaultFieldStyles already contains classNames and it seemed redundant, but I will change it back so that one may implement a custom version locally (which is not currently the case).

});
}
}
Expand Down