- Issue created by @wim leers
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Maybe this is caused by the logic in
workaroundAddDefaultValuesMissingFromClientSideModel()
having been moved into\Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\GeneratedFieldExplicitInputUxComponentSourceBase::clientModelToInput()
and then tweaked:foreach (($client_model['source'] ?? []) as $prop => $prop_source) { - if ($violations === NULL && !\array_key_exists($prop, $client_model['resolved'])) { - // Valueless prop, for the case where only a default is provided for the - // preview, not for storing. - // @see ::exampleValueRequiresEntity() - // @see ::getClientSideInfo()
to:
+ catch (\OutOfRangeException | \OutOfBoundsException) { + if (($violations === NULL || + (\array_key_exists('value', $prop_source) && $prop_source['value'] === $default_source_value)) && + !empty($prop_value)) { + // Valueless prop, for the case where only a default is provided for + // the preview or the initial state of the component inputs form, but + // not for storing. + // @see ::exampleValueRequiresEntity() + // @see ::getClientSideInfo()
In there,
$default_source_value === []
, but$prop_source['value'] === NULL
, so the branch is never entered.Quoting the best most precise comment that explains this:
// The empty array is stored to signal this is an SDC prop (optional or // required) whose example value would need an entity to be created, // which is not allowed. // @see ::exampleValueRequiresEntity() [] => FALSE,
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
As I dug into this, it seems that the problem is bigger still: it seems you cannot actually add
image-optional-with-example-and-additional-prop
norimage-optional-without-example
to the canvas anymore:index.js?v=1:150 Uncaught TypeError: Cannot read properties of undefined (reading 'resolved') at index.js?v=1:150:82549 at Array.forEach (<anonymous>) at s (index.js?v=1:150:82482) at index.js?v=1:150:82941 at index.js?v=1:52:19682 at index.js?v=1:235:21188 at It.<anonymous> (index.js?v=1:235:21575) at _Fe (index.js?v=1:183:10830) at Gs (index.js?v=1:183:11430) at It._onDrop (index.js?v=1:183:27942)
which is this line:
// These will be needed when we support client-side preview updates. initialData.resolved[propName] = prop.default_values.resolved;
which was modified in 📌 Split model values into resolved and raw Active , which appears to previously have been relying on a fallback.
- First commit to issue fork.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
We have an e2e for this and it is passing in HEAD https://git.drupalcode.org/project/experience_builder/-/jobs/4864263#L1774
And I just verified it locally
Ah, but that's a required image - not optional.
Picking this up
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
So turns out the issue was in the line of code we were iffy about in the review!
Added some fixes and a test 🤞
-
wim leers →
committed 6dd48129 on 0.x authored by
larowlan →
Issue #3517102 by larowlan, longwave, wim leers: Regression caused by #...
-
wim leers →
committed 6dd48129 on 0.x authored by
larowlan →