Overview

Reading https://git.drupalcode.org/project/canvas/-/merge_requests/399/diffs#not... for #3557272: BE: Support removing a slot from a code component made me review \Drupal\canvas\ComponentSource\ComponentSourceBase::generateVersionHash and specifically \Drupal\canvas\ComponentSource\ComponentSourceBase::normalizeSlotDefinitions.
I noticed that changing a slot title or examples causes a new component version.

Given this definition

slots:
  content:
    title: Content
    description: Content to display below the greeting
    examples:
      - <div>Example slot content</div>

The normalized slot definitions would be:

[
  'content' => [
    'title' => 'Content',
    'example' => '<div>Example slot content</div>',
  ],
]

I don't think it is reasonable to have the title or example be considered as they do not impact the component's usage.

Proposed resolution

Revise normalizeSlotDefinitions to only return the keys for slots in their defined order.

User interface changes

Comments

mglaman created an issue. See original summary.

wim leers’s picture

Title: Changing a slot name or examples should not generate a new component version » Changing a slot name or examples should not generate a new Component config entity version
Component: Component sources » Config management
Issue tags: +Needs tests

Agreed. Changing the slot machine name should trigger it, but not any of its metadata.

Thanks for reporting this! ❤️

wim leers’s picture

wim leers’s picture

Title: Changing a slot name or examples should not generate a new Component config entity version » Changing a slot's metadata (title/examples) should not generate a new Component config entity version