Problem/Motivation

UI Suite Bootstrap sometimes use empty links to build separators:

  settings:
    content:
      type: "links"
      label: "Content"
      preview:
        - title: "Dropdown header"
          link_attributes:
            class: [dropdown-header]
        - {}
        - title: "Separated link"
          url: '#'

https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/templ...

This is triggering an error:

[content[5].title] Integer value found, but a string is required

See #3412076: [5.1.0] Conversion to SDC & UI Patterns 2.x

Proposed resolution

We may need to remove required: title from links prop type schema in UI Patterns 2.x: https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Plugin/U...

 *   schema = {
 *     "type": "array",
 *     "items": {
 *       "type": "object",
 *       "properties": {
 *         "title": {"type": "string"},
 *         "url": { "$ref": "ui-patterns://url" },
 *         "attributes": { "$ref": "ui-patterns://attributes" },
 *         "link_attributes": { "$ref": "ui-patterns://attributes" },
 *         "below": { "type": "array", "items": { "type": "object" } }
 *       },
 *       "required": {"title"}
 *     }
 *   }

But this required property may be necessary to not catch any array of objects. So we may add an anyOf with the 2 situations:

  • empty object
  • object with required title

User interface changes

No

API changes

Not breaking

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

musa.thomas’s picture

Assigned: Unassigned » musa.thomas
pdureau’s picture

Assigned: musa.thomas » pdureau
Status: Active » Needs work

  • pdureau committed bf75e31d on 2.0.x
    Issue #3447902 by pdureau: Allow empty link in links prop type
    
pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.