In T357718: Support schema references, we added support for JSON Schema references. The referenced field's name is then used to determine what control type is used. For example, the MediaWiki.Extension.CommunityConfiguration.Schemas.MediaWiki.MediaWikiDefinitions::PAGE_TITLE reference is used to trigger the PageTitleControl.
Unfortunately, when one uses references without intending to trigger a special control type, and uses an unrecognized reference name, it does not work. The form just renders itself empty, while I would expect it to render using whatever the default control type would be used, see screenshot:
There is nothing relevant logged in the console.
Used schema
This is the schema I was using as part of T360471:
class GrowthDefinitions extends JsonSchema { public const TEMPLATE_BASED_TASK = [ self::TYPE => self::TYPE_OBJECT, self::PROPERTIES => [ 'disabled' => [ self::TYPE => self::TYPE_BOOLEAN, self::DEFAULT => false, ], 'templates' => [ self::REF => [ 'class' => MediaWikiDefinitions::class, 'field' => 'PageTitles' ], ], ] ]; } class SuggestedEditsSchema extends JsonSchema { public const copyedit = [ self::REF => [ 'class' => GrowthDefinitions::class, 'field' => 'TEMPLATE_BASED_TASK' ], ]; }
When I copy TEMPLATE_BASED_TASK under SuggestedEditsSchema::copyedit, it works as expected.
Solution:
Instead of using $ref name to determine what component to display, use a class field name, which would include the name of the component (possibly represented as a PHP class name). Then, if we inline the references when processing the schema (presumably through a flag to ReflectionSchemaSource::loadAsSchema()), we can use that new field to determine the component on the client side, without having to traverse the schema again.