pseudo pattern does not override arrays, rather merges them. Unexpected, is it a bug?
I think I've found a bug with pseudo patterns when the value is an array and the the pseudo pattern overrides the array, the parent array values are still present in the child array value. In other words a merge happens, rather than an override. I've attached two .json files to show what I mean (ignore the .txt extensions that was so that github would accept them) and the .twig file. The problem is that when the pseudo pattern is rendered the collections loop contains all the values of the parent, with just the first value overridden; I'm expecting that he pseudo pattern would only contain a single array value, or a length of 1. I'm using twig as the templating engine.
[email protected] collection-ui.json.txt collection-ui~noscroll.json.txt
@aklump -
By definition pseudo-patterns inherit data from the parent template. It's how the feature is expected to work. For example, this way someone could provide data for a template, create a pseudo-pattern of the template and not need to duplicate all of the content for that template but rather add/override only parts of it. The only way to avoid this in your case would be to have a thin JSON file associated with a parent pattern and then two pseudo-patterns that show the separate implementations of the pattern.
I think this is related to pattern-lab/patternlab-php-core#16 and that in many cases at least it would be useful if arrays weren't merged even in pseudo-patterns.
@aleksip-
If I determine a new data merge strategy it will be a global data merge strategy. That said, a pseudo-pattern will always inherit data from its parent which it appeared was the issue here. I won't be looking at that particular issue until September at the earliest. I'm going to knock out the remaining spec items for v2.0
Well, shit. Accidentally hit comment and can't edit on mobile..
Going to knock out the remaining items for v2.* and then look at some of major under the hood things like merge strategy. That would be a backwards breaking change so it'd be useful to have in v3.* though I'll probably still have an out to continue using the current strategy.
@dmolsen Sounds good! Just making the connection to the existing core issue, as I believe this is about the same case regarding often expected/desired behaviour with array values. So maybe this Drupal Edition issue can be closed as a duplicate?
i have a problem with psuedo patterns too , in my case psesudo patterns doesn't inherit data from parent pattern. i try with and without plugin-php-data-inheritance