Overview
#3510896: Add a new internal HTTP API for candidate `DynamicPropSource`s to enable a `ContentTemplate` UI built a HTTP API on top of FieldForComponentSuggester.
That's been around for >1 year and never used in the UI. So the labels are developer-supporting, not end-user supporting. But confusing.
- ✅ Too verbose:
This Article's Title→ justTitle - 🟡 Way too verbose when matching subsets that do NOT include the main property (or a computed property depending on the main property):
Subset of this Article's field_silly_image: alt (1 of 7 props — absent: entity, title, width, height, srcset_candidate_uri_template, src_with_alternate_widths)switch to a nested structure: just{Silly Image: {Alternative Text}, to allow for a nested contextual menu to be presented in the UI being added at #3541037: Allow linking `ContentTemplate` SDC/code component instance props to fields (aka finally use `DynamicPropSource`s!). - ✅ Way too verbose when matching subsets that DO include the main property (or a computed property depending on the main property):
Subset of this Article's field_silly_image: src_with_alternate_widths, alt, width, height (4 of 7 props — absent: entity, title, srcset_candidate_uri_template)→ switch to justSilly Image - ✅ The ordering does not match the mental model of the site builder: it should match the order of the
EntityFormDisplay.
Proposed resolution
See above!
Basically, refactor to be able to remove
// Generate a label for the suggestion:
…
// - one that describes the subset of the entity field otherwise,
// with explicit (developer-friendly, user-overwhelming) info on
// which field props are present vs absent.
User interface changes
#3541037: Allow linking `ContentTemplate` SDC/code component instance props to fields (aka finally use `DynamicPropSource`s!) becomes much better 😊
| Which | Before | Interim (#34) | After |
|---|---|---|---|
type: integer |
![]() |
![]() |
![]() |
type: string, format: uri-reference, x-allowed-schemes: [http, https] |
![]() |
![]() |
![]() |
(Note that this is still not using the "proper" hierarchical UI, but this visualizes what that WILL show. See #3548322: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag.)
Issue fork canvas-3547598
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:
Issue fork experience_builder-3547598
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:
- 3547598-better-dynamic-prop-source-suggestions
compare






Comments
Comment #2
wim leersComment #5
wim leersStep 1 is done: https://git.drupalcode.org/project/canvas/-/merge_requests/107/diffs?com... passed tests.
Comment #6
wim leersFYI the "subset" stuff was introduced in #3512433: Provide visibility into which (core) field types (74%), field type props (63%) can be mapped into Content Type Templates vs not, and which field widgets (36%) are supported (again, for developer-facing purposes).
Comment #7
wim leersStep 4 is done: https://git.drupalcode.org/project/canvas/-/merge_requests/107/diffs?com...
Comment #8
wim leersLOL, apparently I wrote
back in #3512433: Provide visibility into which (core) field types (74%), field type props (63%) can be mapped into Content Type Templates vs not, and which field widgets (36%) are supported 🤣
Comment #9
wim leersStep 3 is done: https://git.drupalcode.org/project/canvas/-/merge_requests/107/diffs?com...
Comment #10
wim leersStep 2 is done partially: https://git.drupalcode.org/project/canvas/-/merge_requests/107/diffs?com...
→ now shows as
Silly image (only width, for example.Comment #11
wim leersThe current MR represents all changes that can happen without drastically changing #3541037: Allow linking `ContentTemplate` SDC/code component instance props to fields (aka finally use `DynamicPropSource`s!), too.
What remains: generating a nested structure. However, what we failed to discuss/realize yesterday, but do need to solve somehow, is the distinction between nesting for:
Because it's possible that both occur!
Quotes from the test coverage, for datetime string matching:
and for UUID matching:
and for integer matching
👆 we need to decide how we want to present those; presenting the same is probably not going to make a lot of sense if executed in the simplest way, because in that last example, we'd present the following tree:
Either way, what's in this MR causes zero disruption to #3541037: Allow linking `ContentTemplate` SDC/code component instance props to fields (aka finally use `DynamicPropSource`s!), so landing this MR first 👍
Comment #13
wim leersFor the explanation + question in #11.
Comment #14
lauriiiI don't see why #11 couldn't be implemented in a nested tree of dropdowns? It is just that in the case of a reference field that doesn't allow additional properties, you'd have to go through another level of nesting which seems fine as the first iteration of this – it's still much better than showing them all as a single list. We can potentially apply some optimizations on that in future.
Comment #15
wim leersFrom a technical POV, it can. That's literally what I illustrated in the code blocks.
From a usability POV, I think it's really bad. Because in some cases, the nesting means following an entity reference, in other cases it means picking a single field property of the field in the top level.
Comment #16
wim leersPoint 4 in the issue summary (matching form display order) doesn't work correctly. Root cause:
EntityFormDisplay::getComponents()confusingly doesn't return them in the right order 🙃Comment #19
wim leersWow, now GitLab is broken — the branch points to the open MR at https://git.drupalcode.org/issue/canvas-3547598/-/merge_requests/129, but that is a 404 🙃
Comment #22
wim leers#3548322: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag is the FE follow-up to implement #11 at the UI level. @lauriii responded in #14, but incompletely. See #15 for the outstanding question.
Comment #23
hooroomooWe can do something like this where we utilize separators and labels to differentiate between a
field pointing to a field on another entityand afield of which only a subset is consumed (and this could also be a reference field!).I mocked this up in Figma using the example @wimleers gave in #11 (last code block):
So use a label in this case ("File") for fields for another entity and add a separator after it.
OR 'File' can open its own menu with its options.
Comment #24
wim leersComment #25
lauriiiFYI, I provided some direction in #3548322-13: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag for the UX.
Comment #26
hooroomooExpected API here :-)
And have it in a way where the frontend can just render the JSON directly without any re-ordering/manipulating based on @lauriii's guidelines in #25?
idwould just be used by the frontend for the uniquekeyrequired in a React list item so the frontend doesn't have to generate its own.Comment #27
hooroomooComment #28
wim leersIf somebody wants to pick this up before me (please do!): this requires refactoring
\Drupal\canvas\ShapeMatcher\FieldForComponentSuggester::structureSuggestionsForResponse()to output the structure @hooroomoo outlined in #26.Comment #29
wim leersComment #31
wim leersMade good progress on this today. Sprinkled 🚧 comments to pick this up tomorrow. Will finish then.
Comment #32
wim leersTests passed! Next up: making it work for multi-bundle reference expressions; those test cases had been commented out to get the bulk of this MR going, because they require extra complexity (introduced by #3530521: Decouple image shape matching from the `image` MediaType: support matching multiple bundles of a single MediaSources (`image`)).
Comment #33
wim leersFully green! 🥳
Time now to generate the JSON structure outlined by @hooroomoo in #26.
Comment #34
wim leersTime to visualize the progress. See the updated issue summary.
Now it's time to aim for meeting all of the requirements set forth by @lauriii at #3548322-13: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag:
Working on #3 now.
Comment #35
wim leersFix HTML.
Comment #36
wim leers#3 is implemented 👍
That leaves now only the hierarchical response structure outlined by @hooroomoo in #26.
Comment #37
wim leersAs the screenshots in the "UI changes" section illustrate, this is already a big leap forward.
The UI will take advantage of this in the follow-up this unblocks, see #3548322-16: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag and the subsequent comment for guidance.
Comment #38
wim leersprimary-panel.cy.js'spreviews components on hovertest case seems to be failing consistently on CI for this MR (passing consistently on 1.x HEAD), but locally it passes just fine:Re-tested a 3rd time: https://git.drupalcode.org/project/canvas/-/jobs/6811379 🤞
Worst of all: that is testing component previews in the list of components available to instantiate, which this MR is not even getting close to touching any code path for 😭
@jessebaker touched that file yesterday, so I'm hoping he has a hunch…
Comment #39
wim leersOMG — now it passed: https://git.drupalcode.org/project/canvas/-/jobs/6811379 (but now
navigation.cy.jsfailed 🤷♂️ — random fails are such a PITA!).Comment #41
wim leersSee y'all in #3548322: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag! 🎉