- Issue created by @Chris64
- 🇫🇷France Chris64 France
Here it is,
/** * Implements hook_page_attachments_alter(). */ function ligamen_page_attachments_alter(array &$attachments) { $attachments['#attached']['library'][] = 'ligamen/ligamen-color-theme'; $routeMatch = \Drupal::service('current_route_match'); $route_name = $routeMatch->getRouteName(); if ('entity.node.canonical' === $route_name) { $node = $routeMatch->getParameter('node'); if ('arbre' === $node->bundle()) { $to_remove = [ 'system/base', 'classy/base', 'core/normalize', 'bartik/global-styling', 'olivero/global-styling', 'adminimal_admin_toolbar/adminimal-admin-toolbar', 'quickedit/quickedit', 'contextual/drupal.contextual-links' ]; foreach($to_remove as $library) { $index = array_search($library, $attachments['#attached']['library']); if (FALSE !== $index) { unset($attachments['#attached']['library'][$index]); } } } } }
The remaining libraries after that,
( [3] => core/drupal.active-link [4] => ligamen/ligamen-color-theme )
It works on D9, and D10.0. Here the critical library is
global-styling
. - 🇫🇷France Chris64 France
@cilefen, we sought more elements about the problem and we get one. But strange. No trivial links to css files seen. Many experiments to identify the culprit in the
core/drupal.message
library dependencies failed. But found a very simple change who made our problem disappear: rename the library incore.libraries.yml
:drupal.message
->drupal.messageb
(two occurrences). - 🇫🇷France Chris64 France
New elements. The problem comes from
olivero/drupal.message
, throughlibraries-extend
. The above rename cause the avoidance of this extension. - 🇫🇷France Chris64 France
From above in
core/themes/olivero/olivero.libraries.yml
the dependencies chain is,drupal.message: ... dependencies: - olivero/messages
messages: ... dependencies: - olivero/global-styling
and the unwanted library
olivero/global-styling
is got. - 🇫🇷France Chris64 France
Comparing Drupal 9.5 and 10.1 about Olivero messages libraries, a major change concerns
olivero/messages
, inolivero.libraries.yml
,dependencies: - core/drupal.array.includes
->
dependencies: - olivero/global-styling
For both
css/components/messages.css
is underolivero/global-styling
. - 🇮🇳India shobhit_juyal New Delhi
Hi @Chris64,
Further should we exclude drupal.message library as well ?
- 🇫🇷France Chris64 France
Hi @shobhit_juyal. The drupal.message library should not be exclude. But for my purpose the current approach in Drupal 10.1 causes some problems.
css/components/messages.css
is requested, but througholivero/global-styling
a lot of other and unnecessary files are gotten. - Status changed to Needs review
over 1 year ago 3:55am 5 July 2023 - last update
over 1 year ago 29,443 pass - 🇮🇳India gauravvvv Delhi, India
global-styling is what includes js/navigation-utils.js, which initializes Drupal.olivero. Any code using Drupal.olivero like messages.js using Drupal.olivero.closeMessage needs to have that run first. For that I have added
olivero/navigation-base
as a dependency on part of global styling. - Status changed to Needs work
over 1 year ago 12:11pm 5 July 2023 - 🇺🇸United States smustgrave
If #14 is the fix the title and issue summary need to be updated. As the patch does not make sense based on the title.
Also will need a test case showing the problem.
- 🇮🇳India gauravvvv Delhi, India
Root cause of this issue is already there in the issue summary. you can see it here → .
A dependency chain was there which causes the issue.
messages
library has dependency of global-styling anddrupal.message
has the dependency ofmessages
library. That's why we're unable to remove attachments throughhook_page_attachments_alter
.I have removed the global library dependency and added the required files to
messgaes
libarary.Status is NW, as need to add tests
- last update
over 1 year ago Build Successful - 🇫🇷France Chris64 France
Apply 3357728-14.patch → : OK: our problem disappears. Since the two last .css are as expected,
<link rel="stylesheet" media="all" href="/modules/contrib/admin_toolbar/css/admin.toolbar.css?rxe502" /> <link rel="stylesheet" media="all" href="/core/themes/olivero/css/components/progress.css?rxe502" />
Apply 3357728-16.patch → : PB: an error appends,
Error : Undefined constant "CSS_COMPONENTS" dans constant() (ligne 184 de */web/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).
May be an other problem? Drupal 10.1.1.The corresponding line 184 is
$options['weight'] += constant($category_weight);
inforeach (['js', 'css'] as $type) { // Prepare (flatten) the SMACSS-categorized definitions. // @todo After Asset(ic) changes, retain the definitions as-is and // properly resolve dependencies for all (css) libraries per category, // and only once prior to rendering out an HTML page. if ($type == 'css' && !empty($library[$type])) { assert(static::validateCssLibrary($library[$type]) < 2, 'CSS files should be specified as key/value pairs, where the values are configuration options. See ht> assert(static::validateCssLibrary($library[$type]) === 0, 'CSS must be nested under a category. See https://www.drupal.org/node/2274843.'); foreach ($library[$type] as $category => $files) { $category_weight = 'CSS_' . strtoupper($category); assert(defined($category_weight), 'Invalid CSS category: ' . $category . '. See https://www.drupal.org/node/2274843.'); foreach ($files as $source => $options) { if (!isset($options['weight'])) { $options['weight'] = 0; } // Apply the corresponding weight defined by CSS_* constants. $options['weight'] += constant($category_weight); $library[$type][$source] = $options; } unset($library[$type][$category]); }
- 🇫🇷France Chris64 France
For the error see https://www.drupal.org/project/void/issues/3060386 → .
- 🇫🇷France Chris64 France
The change
components:
->component:
solves this problem #17 🐛 Break dependencies chain in olivero.libraries.yml Needs work . - 🇪🇸Spain psf_ Huelva
I do the change by Chris64 in #19.
I'm sorry, I don't know how do the interdiff.