Problem/Motivation
In #3510711: Links prop type is detected before Breadcrumb adapter, Liam wrote:
It converts Url objects into strings, but radix:dropdown-menu needs them to be Url objects. So, I want to understand what causes LinksPropType to be executed on these values.
Indeed, url sub-property in the items component prop are not defined as string but as object in radix:dropdown-menu
url:
type: object
properties:
options:
type: object
...
So, the items prop must not be processed as LinksPropType which is expecting a string for the url sub-property:
url:
type: string
format: iri-referenceIt must be ignored.
Proposed resolution
Maybe there is something to do in the Drupal\ui_patterns\SchemaManager\CompatibilityChecker service where I see a missing check in object properties.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | ui_patterns-check_object_properties-3571216-18.patch | 14.02 KB | liam morland |
| #15 | ui_patterns-check_object_properties-3571216-15.patch | 13.89 KB | liam morland |
Issue fork ui_patterns-3571216
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 #2
liam morlandThanks for creating this.
Comment #4
pdureau commentedFirst proposal pushed. I twas a big work, bigger than expected, but a necessary work.
The main fix:
tests/fixtures/CompatibilityCheckerData.ymlto cover the situations when we want to check the inner properties of a JSOn object, so forAttributesPropTypeandLinksPropTypesrc/SchemaManager/CompatibilityChecker.php, we are now looping on objectproperties(andpatternProperties) and checking their compatibility.However, something was still wrong, some tests (automated or manual) were still KO. Because the current logic of JSON schema resolving in
ComponentPluginManagerwas done separately from theCompatibilityChecker, with only a specific "conciliation" check for the root of the prop schema.We didn't notice that until now because the only cases with JSON schema references not in the root of the prop schema were...
LinksPropType;)So, other fix:
src/ComponentPluginManagertosrc/PropTypePluginManagerReferencesResolver::resolve()so we are testingidproperty instead of$refReferencesResolver::resolve()inComponentPluginManagerbut we add a call fromsrc/SchemaManager/CompatibilityChecker.php, before callingCanonicalizer::canonicalize()in order to be sure both schema are resolved, so comparable.ui_patterns.services.ymltotests/src/Unit/SchemaManager/CompatibilityCheckerTest.phpto inject theReferencesResolvertoCompatibilityCheckerCanonicalizer::canonicalize()becauseReferencesResolversometimes transform arrays inStdClass.Comment #5
pdureau commentedLiam, is this MR fixing your issue?
---
Mikael, Christian, let's talk before merging.
This is a big change, in a deep, tricky and strategic part of the module, so lets' be extra careful.
Let's also check the performance because the mechanisms altered are processing heavy. I don't believe the change will hut performance (I kind og hope they may improve it a bit), but let's also be careful there.
Comment #6
liam morlandUnfortunately, I am not able to reproduce the problem anymore. The site is in major development. I uninstalled
ui_patternsand putting it back now doesn't cause the problem, presumably due to other changes in the site.Comment #7
pdureau commentedDon't worry, your input was very useful to identify an issue which have been hidden for one full year. Thanks a lot.
Comment #8
liam morlandThanks. I encountered what is likely a related problem. Some block titles are being replaced with "1" (which suggest to me casting a Boolean to a string). If I uninstall
ui_patterns, it no longer happens. The merge request does not fix the problem.Comment #9
pdureau commentedCan you tell me more? What is the component prop definition?
Comment #10
liam morlandIn our theme, we call SDC
radix:block. At this point, the block label is correct. In theradix:blockTwig file, the label has become "1". This is the label prop definition:In the preprocess for our SDC, the label is a string.
I wonder if it is converting the string to Boolean, which would be true, and that gets output as "1".
Comment #11
pdureau commentedThis prop schema:
Can be caught by:
type: 'boolean'type: 'string'Both plugins have the same priority level ("1") so the alphabetical order is ruling the discovery and this prop is managed by
BooleanPropType.My guts feeling is to ask: why
['string', 'null', 'boolean']? I struggle to understand what this schema is trying to achieve here, because the prop is only used in:And heading's
contentprop hastype: stringschema. So, it may look like somehtign related to component authoring.But our philosophy in UI Patterns is to adapt our logic to component implementations found in the wild, instead of dictating component authoring. We will not ask you to change the definition to fit with better with our module. So, maybe playing with priority order, to be sure the prop is maanged by
StringPropTypeplugin, can be evaluated.Comment #12
just_like_good_vibesHello, can someone review the work please :) ?
Comment #13
pdureau commentedRebased.
As said before, this is a big change, in a deep, tricky and strategic part of the module, so lets' be extra careful.
Let's also check the performance because the mechanisms altered are processing heavy. I don't believe the change will hurt performance (I kind of hope it may improve it a bit), but let's also be careful there.
Comment #14
liam morlandThis fixes the breadcrumbs for me. It does not fix the block titles, which still appear as "1".
Comment #15
liam morlandCurrent state of merge request.
Comment #16
pdureau commentedThe MR is addressing the links issue and it is fortunate (but not that surprising) it also fixes #3510711: Links prop type is detected before Breadcrumb adapter.
Comment #17
liam morlandI added a change which fixes the block titles appearing as "1". This is done by increasing the priority of
StringPropType.Comment #18
liam morlandCurrent state of merge request.
Comment #19
just_like_good_vibeshello guys, i added a small fix to make the MR be green.
Comment #20
just_like_good_vibesi just added some little more code and more tests. i fixed the todo about additionalProperties.
Comment #22
just_like_good_vibes