Overview
After adding a component with optional image and a default value, the default value is gone if I change any of the props.

Tested this with the hero component from SDDC: https://git.drupalcode.org/project/demo_design_system/-/tree/1.0.x/stars....
Proposed resolution
User interface changes
| Comment | File | Size | Author |
|---|---|---|---|
| CleanShot 2025-02-20 at 11.16.26.gif | 892.05 KB | lauriii |
Issue fork experience_builder-3508077
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:
- 3508077-default-image-lost
changes, plain diff MR !733
- 3508077-release-patch
compare
Comments
Comment #2
wim leersPlease share the SDC with which you tested this. Otherwise we have to waste time figuring out how to reproduce this.
Comment #3
lauriiiTested this with the hero component from SDDC: https://git.drupalcode.org/project/demo_design_system/-/tree/1.0.x/stars....
Comment #4
wim leersWill investigate Monday.
Comment #5
longwavePicking this up as I've been solving other image issues in #3507641: Allow components containing non-required images and no examples to be placed
Comment #6
tedbowChatted with @longwave. I am going to take a look at this since he is on another issue
Comment #7
wim leersLovely, thanks! 🙏
Comment #9
tedbowI am wondering if this is front-end issue. I am not super familiar with how the front-end sends back the form inputs but this is what I am seeing using the
optional-props-imagecomponent I added in the MRBetween step 3 and 4, I debugged the call to
\Drupal\experience_builder\Controller\ApiLayoutController::patch()The body of the request has model->source->heading and model->resolved->heading but 'image' is not under either shouldn't it be sent back under 'source' even though it is empty?
Looking at the value in the client form of
edit-form-xb-propsI seeSo it does have the info for image. should it be sending back what it has?
Comment #10
tedbowManually testing the MR now I can get to not lose the default image when changing the heading property.
My solution was to set the props that were missing from the client in
\Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\GeneratedFieldExplicitInputUxComponentSourceBase::clientModelToInputNot knowing this part of the code it seems reasonable to allow the client the skip props that don't have a value, since the server can figure out this info.
Will see if this breaks other tests
Comment #11
tedbowComment #12
wim leers@tedbow: when it's green, can you please mark and assign to @longwave? 🙏 He knows this bit best.
Comment #13
longwaveThis seems related to Wim's analysis in #3507929-25: Allow adding "image" props in the code component editor.. not sure the fix is quite right but it's in the right location, will try to look later on today.
Comment #14
wim leers#13: I had a similar hunch!
Comment #15
longwaveAdded a test for this and fixed it to only apply to object shapes; this works but it feels wrong? Also I don't like the way the fallbacks are checked both before and then after the inputs are set up, but too tired now to figure out how to refactor it nicely. The test passes locally though!
Comment #16
longwaveWondering if this it the right way at all, maybe we should be altering the SDC component info much earlier to remap the example/default path instead of trying to map it in via a prop source.
Comment #17
kristen polI've been testing https://github.com/phenaproxima/xb-demo and ran into this issue and using the MR on my local fixed this issue.
Comment #18
pameeela commentedAlso tested with this and it worked :)
Comment #21
wim leers#15: AFAICT this is hugely overlapping with #3509608-9: Unable to save an optional image with its default value (because it does not correspond to a Media entity): allow saving DefaultRelativeUrlPropSource?! I bet you write in #9 it feels wrong for lots of reasons, and I articulated those reasons in #3509608-9?! 😅
Comment #22
wim leersComment #24
traviscarden commented👆 Rebased onto
0.x.Comment #25
wim leersI bet #3493943: SDC+JS Component Sources: split default values into `resolved` and `source` will help with this.
Comment #26
nagwani commentedComment #27
wim leersUnfortunately, #3493943: SDC+JS Component Sources: split default values into `resolved` and `source` hasn't been completed yet, even though it would have removed the need for this work-around. @longwave confirmed at #3493943-20: SDC+JS Component Sources: split default values into `resolved` and `source` that that is the proper fix.
So, to ease the pain during DrupalCon (next week!), we intend to land this work-around, knowing full well that #3493943 will again remove it.
Comment #28
wim leersGoing ahead and merging this to fix this ahead of DrupalCon next week.
But https://git.drupalcode.org/project/experience_builder/-/merge_requests/7... identified that this is actually being fixed in the wrong place: it's not broken on the server side, but on the client side: https://git.drupalcode.org/project/experience_builder/-/merge_requests/7....
I'm assuming #3493943: SDC+JS Component Sources: split default values into `resolved` and `source` will fix that, too.
Comment #29
wim leersComment #31
kristen polThanks!!!
Comment #32
effulgentsia commented