Overview
Quoting @penyaskito from #3470422-68: Handle components provided by ComponentSources IMPLICITLY disappearing: gracefulness when developing SDCs: SDCs may appear/disappear from one request to the next:
why the client sends
form_canvas_props: undefined, instead of an actual JSON blob. (When the fallback source is in use, the client should send the model it has for this component instance, not the values for the component instance form.)
See https://git.drupalcode.org/project/canvas/-/merge_requests/142#note_598244, which was forced to introduce a server-side work-around which is causing further pain in subsequent MRs: https://git.drupalcode.org/project/canvas/-/merge_requests/220/diffs#not....
Worse, since then, we've regressed: block component instances (only for block component instances could form_cavas_props: undefined get sent!) no longer offer the fallback behavior
- I placed/instantiated core's "branding" block.
- Then deleted
core/modules/system/src/Plugin/Block/SystemBrandingBlock.php drush cr- When editing again:

It also means \Drupal\Tests\canvas\Kernel\ComponentInstanceFormTest::testBlockComponentThatHasGoneAway() is testing a client reality that has vanished — (what should have been an E2E test)
Proposed resolution
- 🚢 MR#1: Improve comment clarity for the complex fallback logic that #3519168: Handle components provided by ComponentSources EXPLICITLY disappearing — enables deleting JS components that are in use introduced in
\Drupal\canvas\Form\ComponentInstanceForm::buildForm(). (The lack of sufficient comments has made this much harder to work on.) - MR#2:
- Fix the JS error in the GIF in the STR above.
- Remove the server-side work-around
- Determine the root cause of the bug on the client side and fix it.
User interface changes
Works again like #3519168: Handle components provided by ComponentSources EXPLICITLY disappearing — enables deleting JS components that are in use intended, but now without special babysitting for component sources other than SDC/code components. 👍
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | broken block component instance form crashes.gif | 187.59 KB | wim leers |
Issue fork canvas-3558721
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
Comment #3
wim leersAlso credited @penyaskito for his original work in identifying the bug and figuring out a viable work-around: https://git.drupalcode.org/project/canvas/-/merge_requests/142/diffs#not....
P.S.: I suspect this goes all the way back to how support for block forms was introduced in #3491978: Implement saving block settings forms.
Comment #4
wim leersBump.
Comment #5
wim leersLooks like we actually don't need that, and it passes tests? 🤔
Comment #6
wim leers#3558448: UI must only set `value` on `StaticPropSource`s, not on `DynamicPropSource`s nor `HostEntityUrlPropSource`s landed, which seems to have touched this.
Comment #7
wim leers#3470422: Handle components provided by ComponentSources IMPLICITLY disappearing: gracefulness when developing SDCs: SDCs may appear/disappear from one request to the next significantly changed the lines this was updating; hope I got the update right.
EDIT: apparently I was the one who removed the block-specific bits over at https://git.drupalcode.org/project/canvas/-/merge_requests/220/diffs?com... 🤯 No recollection of this.
Comment #8
wim leersAFAICT #3577219: Add Multi-Value Image/Video Prop Support (UI)'s https://git.drupalcode.org/project/canvas/-/merge_requests/755 addressed this:
Merged in upstream. Re-testing.
Comment #9
wim leersImproved the clarity of the
elsebranch (meaning "component powering this component instance is broken").This actually brought us to failing tests that fail for the very reason this issue was opened: the client is sending nothing, whereas it should send the client-side data model it does have. IOW:
\Drupal\Tests\canvas\Kernel\ComponentInstanceFormTest::testBlockComponentThatHasGoneAway()is replicating the client-side bug in a PHPUnit test;That
json_decode('undefined')bit at the end is the problem.Reproducibility in current UI
So I set out to reproduce this.
core/modules/system/src/Plugin/Block/SystemBrandingBlock.phpdrush crThat means the answer to in the issue summary is: "cannot reproduce at all", so the server-side work-around by definition is not necessary right now 😅
Meaning you can no longer even get to the component instance form to recover values (which was the very purpose of #3519168: Handle components provided by ComponentSources EXPLICITLY disappearing — enables deleting JS components that are in use).
It also means
\Drupal\Tests\canvas\Kernel\ComponentInstanceFormTest::testBlockComponentThatHasGoneAway()is testing a client reality that is no longer a reality — an inherent risk of replicating client behavior in a PHPUnit test.Comment #10
wim leersUpdated IS.
Proposing 2 MRs:
Comment #12
wim leersBumping to critical because this will lead to:
NR for the first MR. That can land and improve the clarity of what needs to happen.
Comment #13
wim leersComment #15
wim leersLanded MR #1. MR #2 updated with pointers.
Comment #16
wim leers