- Issue created by @wim leers
- πΊπΈUnited States Kristen Pol Santa Cruz, CA, USA
To be clear, this is so you can have a multivalue prop? Like multiple links?
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
#2: yes.
(Which is what you referred to in #3454125-70: Implement temporary design system for the DrupalCon Barcelona demo β , point 3.
- πΊπΈUnited States Kristen Pol Santa Cruz, CA, USA
Gotcha π thanks for the clarification
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
While this does need design, I think we can lay the shape matching foundations. A conversation with @catch about β¨ JSON-based data storage proposal for component-based page building Active yesterday made me realize that:
- this is more within reach since π Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed than I thought
- having this working for at least
type: array, items: integer
andtype: array, items: string, maxItems: 2
would actually help the discussion over at #3440578
- Merge request !331Draft: #3467870: Support *generating* (not matching) field storage definitions for `{type: array, β¦}` prop shapes β (Open) created by wim leers
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
wim leers β changed the visibility of the branch 3467870-support-generating-not to hidden.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
I've made progress today on updating
FieldTypePropExpression
,StaticPropSource
andEvaluator
to supporttype: array
.How?
By changing
StaticPropSource
to not be required to contain aFieldItemInterface
(i.e. a single field delta), but instead allowing aFieldItemListInterface
too (i.e. multiple field deltas).It's too unorganized right now to push; expect an update tomorrow π
Thanks @catch for nudging me in this direction π
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Just pushed initial test coverage in
PropSourceTest::testStaticPropSource()
, to test it with multiple cardinality:// A simple (expression targeting a simple prop) array example (with // cardinality specified, rather than the default of `cardinality=1`). $simple_array_example = StaticPropSource::parse([ 'sourceType' => 'static:field_item:integer', 'sourceTypeSettings' => [ 'storage' => [ 'cardinality' => 5, ], ], 'value' => [ 20, 06, 1, 88, 92, ], 'expression' => 'βΉοΈintegerβvalue', ]);
It should now fail like this:
1) Drupal\Tests\experience_builder\Kernel\PropSourceTest::testStaticPropSource Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'{"sourceType":"static:field_item:integer","value":[20,6,1,88,92],"expression":"βΉοΈintegerβvalue","sourceTypeSettings":{"storage":{"cardinality":5}}}' +'{"sourceType":"static:field_item:integer","value":null,"expression":"βΉοΈintegerβvalue","sourceTypeSettings":{"storage":{"cardinality":5}}}'
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Yay, from:
1) Drupal\Tests\experience_builder\Kernel\HookStoragePropAlterTest::testPropShapesYieldWorkingStaticPropSources Sample value 88 generated by field type integer for type=array&items[type]=integer is invalid! Failed asserting that two arrays are identical. --- Expected +++ Actual @@ @@ -Array &0 () +Array &0 ( + 0 => Array &1 ( + 'property' => 'ds032jpb' + 'pointer' => '/ds032jpb' + 'message' => 'Integer value found, but an array is required' + 'constraint' => 'type' + 'context' => 1 + ) +)
(IOW: a single integer is passed, when an array of integers is needed)
to β¦ that test passing π€
More coming.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
I was chasing a heisenbug for a few hours today. I then eventually found the root cause.
It happens only for a
list_string
field type with one of its allowed values the empty string:[ 'allowed_values' => [ ['value' => '', 'label' => ''], ['value' => '_blank', 'label' => '_blank'], ], ]
β¦ because somewhere
''
gets cast toNULL
πXB's tests generate a random value to verify the static prop source works end-to-end, and due to the changes in this MR (introducing the use of
FieldItemList
and hence callingFieldItemList::isEmpty()
, which we didn't call before), this:
now resulted in
which is obviously wrong, butcount()
works fine:
β¦ this is valid configuration for the
list_string
field type: its config schema typefield.storage_settings.list_string
does not forbid this.But the UI does forbid it:
which causes:
So probably a fixed
ListStringItem::isEmpty()
that is more strict than the inherited\Drupal\options\Plugin\Field\FieldType\ListItemBase::isEmpty()
's implementation:public function isEmpty() { return empty($this->value) && (string) $this->value !== '0'; }
β¦ would not even be accepted by Drupal core maintainers! π¬
Unfortunately, I lost hours today because of this. If there was config schema validation in place, this would've been sorted out in minutes. π
So: not filing a Drupal core issue, β I can't justify that, because it's a valid use case for SDC, and we can make it work.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
I actually think that matching field instances should be possible too, so broadening the issue title/scope π€
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
type: array
breakthrough β itβs starting to work end-to-end! πSoon: πΌοΈπΌοΈπΌοΈπΌοΈ aka image galleries!
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
100% of remaining test failures are due to not yet supporting finding
DynamicPropSource
s (aka existing entity field instances) for thetype: array
prop shape.That's why I widened the scope in #15 β because I first thought it'd be an order of magnitude harder than supporting
StaticPropSource
s (which is the only thing the XB UI currently supports). But it'd be a shame to let that part "fall behind", so trying to tackle this while my head is in this space π - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
1% of remaining test failures are in the Cypress E2E tests, which makes sense: the Redux integration has only been built with single-cardinality props in mind, that's changing here.
IOW: having this in also empowers π± [META] Redux sync on ALL prop types, not just ones with a single [value] property Active to design a more complete solution.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Merged in all upstream changes.
We may also need to consider this in π Some components cannot be used in XB because UI prevents SDC props being named `name` Active .
- πΊπΈUnited States tedbow Ithaca, NY, USA
@Wim Leers the direction looks good to me!
- Assigned to wim leers
- Status changed to Needs work
about 2 months ago 11:15am 6 January 2025 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
https://nerdy.dev/carousel-adaptive-anchor-positioning-with-calc-in-a-co... would be a fantastic way to demonstrate this!