- Issue created by @mstrelan
- Merge request !3651Issue #3347736: Create new SDC component for Olivero (header-search) → (Open) created by mstrelan
- 🇦🇺Australia mstrelan
Some observations.
The first issue I ran in to was this error:
Twig\Error\SyntaxError: An exception has been thrown during the compilation of a template ("We found an unexpected slot that is not declared: [content]. Please declare them in "search-form.component.yml".") in "olivero:search-form". in Twig\Environment->compileSource() (line 524 of /data/vendor/twig/twig/src/Environment.php).
What is a slot? Where do I find information on slots? After some poking around I eventually realised it refers to
{% block content %}
in the twig template. I had a look at the schema and found slots next to props with the same schema so I added slots to my yaml file. Since it takes the same schema as props I just copy/pasted that directly and left only thecontent
property. That lead to the following error:Drupal\sdc\Exception\InvalidComponentException: Slots can only be declared with the type "string". Slot [content] in component "header-search-narrow" is declared with type "array". in Drupal\sdc\Component\ComponentMetadata->parseSchemaInfo() (line 178 of core/modules/sdc/src/Component/ComponentMetadata.php).
OK, so it can only be a string, what's the point declaring its type if it can only ever be "string"?
The next thing I wondered, do I really have to pass all the variables from one twig to another? And do I need to declare the props for title_prefix, title_suffix, attributes, etc? I've declared them all, but opted not to pass them from the original twig files as that seems to happen automatically.
The final challenge I faced was that the order of the CSS files that were loaded had changed. This meant that the primary button hover/focus/active styles were taking precedence over the custom styles for the search submit button. For now I've added explicit hover/focus/active styles for this button, but it seems we could also just remove the
button--primary
class.I also added a
@todo
comment in the MR wondering if there is a better SDC way of doing this:$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search'];
- e0ipso Can Picafort
This is great feedback! Do you mind if I quote you in the SDC MR so we can talk about it there?
- 🇦🇺Australia mstrelan
No problem at all. I also raised a number of issues against cl_server and sdc_examples modules, but these are less relevant for core.
- Status changed to Needs work
over 1 year ago 3:50am 4 June 2023 - First commit to issue fork.
- Open on Drupal.org →Environment: PHP 8.1 & MySQL 5.7last update
over 1 year ago Not currently mergeable. - Status changed to Needs review
over 1 year ago 4:00am 15 June 2023 - Status changed to Needs work
over 1 year ago 11:47am 15 June 2023 - First commit to issue fork.