`#propsAlter` alters all props simultaneously, `#slotsAlter` does not, despite its name and test coverage

Created on 23 August 2024, 27 days ago
Updated 24 August 2024, 27 days ago

Problem/Motivation

Discovered at #3469442-6: Impossible to drop a component into an empty column of the two .

Quoting \Drupal\KernelTests\Components\ComponentRenderTest::checkRenderElementAlters():

      '#propsAlter' => [
        fn ($props) => [...$props, 'heading' => $this->t('I am another banner')],
      ],

If you put a breakpoint there, you can indeed see all props:

Quoting from that same test:

      '#slotsAlter' => [
        static fn ($slots) => [...$slots, 'banner_body' => ['#markup' => '<h2>Just something else.</h2>']],
      ],

If you put a breakpoint there, you do NOT see all slots, but just the value/contents of one slot at a time:

If you look at the altered result, the problem is clear:

👆 Rather than having added #markup to banner_body, we've altered banner_body => ['#markup' ⇒ …] into banner_body 😅

Steps to reproduce

See above.

Proposed resolution

TBD — AFAICT fixing this requires a BC break? 😬

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
single-directory components 

Last updated 1 day ago

Created by

🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺

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

Comments & Activities

Production build 0.71.5 2024