[2.0.0-alpha3] Allow empty link in links prop type

Created on 17 May 2024, 6 months ago
Updated 24 June 2024, 5 months ago

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 📌 [5.1.x] Automatic conversion to SDC & UI Patterns 2.x Needs work

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

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024