diff --git a/modules/ui_patterns_legacy/src/Template/TwigExtension.php b/modules/ui_patterns_legacy/src/Template/TwigExtension.php index 58ebc0036c177ff838b5ffc5f81e05a254a12767..220fdaef87f05326c736d66a7c79a51563a0a3fa 100644 --- a/modules/ui_patterns_legacy/src/Template/TwigExtension.php +++ b/modules/ui_patterns_legacy/src/Template/TwigExtension.php @@ -56,8 +56,14 @@ class TwigExtension extends AbstractExtension { $element = [ '#type' => 'pattern', '#id' => $id, - '#variant' => $variant, ]; + + // Variant is a JSON-schema enum where empty string is not always allowed. + // Moreover, we don't allow empty variant. + if (!empty($variant)) { + $element['#variant'] = $variant; + } + // We use the compact format, so it will be resolved by // RenderableConverter::resolveCompactFormat() before being converted to // the SDC format. diff --git a/src/ComponentPluginManager.php b/src/ComponentPluginManager.php index cbec4c449b765467ecb7bd7bfec947c5c5c5f921..768b7cc2f21019ab034e701fcba2b91dc40c95f4 100644 --- a/src/ComponentPluginManager.php +++ b/src/ComponentPluginManager.php @@ -163,7 +163,6 @@ class ComponentPluginManager extends SdcPluginManager implements CategorizingPlu } return [ 'title' => 'Variant', - 'type' => 'string', '$ref' => "ui-patterns://variant", 'enum' => $enums, 'meta:enum' => $meta_enums, diff --git a/src/Plugin/UiPatterns/PropType/VariantPropType.php b/src/Plugin/UiPatterns/PropType/VariantPropType.php index ca17553d1cf44f9f9ec33ba6bfaed686298816dd..da53ff769548a9eb05af8722f9456ec3193a92e1 100644 --- a/src/Plugin/UiPatterns/PropType/VariantPropType.php +++ b/src/Plugin/UiPatterns/PropType/VariantPropType.php @@ -14,10 +14,10 @@ use Drupal\ui_patterns\PropTypePluginBase; #[PropType( id: 'variant', label: new TranslatableMarkup('Variant'), - description: new TranslatableMarkup('Prop Type for component variants.'), + description: new TranslatableMarkup('Prop type for component variants.'), default_source: 'select', - schema: [], - priority: 10 + schema: ['type' => ['string'], 'enum' => []], + priority: 1 )] class VariantPropType extends PropTypePluginBase {