While testing Canvas with contrib & custom SDC themes, I have notice than most of our SDC are not loaded and land in Disabled & incompatible components tab.
if ($prop['type'][0] === 'object' && !isset($prop['$ref'])) {
$messages[] = \sprintf('Prop "%s" is of type "object" without a $ref, which is not supported', $prop_name);
continue;
}
In JSON schema, $ref
and type
can technically be met together but they normally don't because the schema resolver is merging the $ref
into the current position, bringing the type with it.
So, expecting to have a type: object
alongside the $ref
is a bit weird and no a lot of SDC themes (except the ones knowing about this Canvas requirement) will have this.
if (in_array($prop_name, $required_props, TRUE) && !isset($prop['examples'][0])) {
$messages[] = \sprintf('Prop "%s" is required, but does not have example value', $prop_name);
}
In JSON Schema, examples (like title
, description
...) is a metadata only for documentation and must not be part of processing.
There is already a JSON property for this: default
which must be used for default value in forms but can also be used for default value while dropping a component.
Moreover, default
is a single value property, and there is no need on picking the first item like what Canvas is currently doing with examples
.
And we can avoid this quirk because JSON schema is expecting default
value to be valid:
JSON Schema does not require that examples must be valid, but we do require the first one to be, as we use it as the default value for the prop.
See also 🐛 DX & authoring experience: for SDC+code components, the example is treated as the default, may not be desirable Active
if ($metadata->schema === NULL) {
throw new ComponentDoesNotMeetRequirementsException(['Component has no props schema']);
}
A lot of SDC in the wild have only slots, so they don't have a props schema. Why not just adding the schema on the fly (or better, fixing the root cause leading to this restrictions) instead of being incompatible with them?
default
instead of examples
Active
1.0
Component sources
It is used to alert the product manager core committer(s) that an issue represents a significant new feature, UI change, or change to the "user experience" of Drupal, and their signoff is needed. If an issue significantly affects the usability of Drupal, use Needs usability review instead (see the governance policy draft for more information).
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.