- Issue created by @_randy
- π©πͺGermany marc.bau
Have seen the same issue and not found a solution yet.
- Status changed to Postponed: needs info
8 days ago 2:45pm 10 September 2024 - πΊπΈUnited States shelane
Can you give me more info on steps to reproduce this issue? What style did you have it set to? What are the options? What is the data type in the view?
- π¨π¦Canada _randy
@shelane
The data in the view is two content types (just regular old nodes).
Configured to show rendered entity content, not fields, using a specific display mode.Format: Bootstrap Grid - Settings were straight out of the box - no changes.
As noted, this worked fine prior to the Beta and RC releases.
Issue is in template_preprocess_views_bootstrap_grid function in views_bootstrap.theme.inc file.
In the alpha version only $vars['row_attributes'] was set to "new Attribute()".
In the latest versions, $vars['attributes'] is set to "new Attribute(['class' => 'grid']);"This creates the issue with Drupal core.
- π©πͺGermany marc.bau
Same here - "Format: Bootstrap Grid - Settings were straight out of the box - no changes."
- πΊπΈUnited States shelane
Interesting. I still haven't been able to recreate the issue. Looking right at the Drupal core views module and their views.theme.inc file uses the
new Attribute
method. For instance:foreach ($variables['rows'] as $num => $row) { $variables['rows'][$num]['attributes'] = []; if ($row_class = $handler->getRowClass($num)) { $variables['rows'][$num]['attributes']['class'][] = $row_class; } $variables['rows'][$num]['attributes'] = new Attribute($variables['rows'][$num]['attributes']); } if (empty($variables['rows']) && !empty($options['empty_table'])) { $build = $view->display_handler->renderArea('empty'); $variables['rows'][0]['columns'][0]['content'][0]['field_output'] = $build; $variables['rows'][0]['attributes'] = new Attribute(['class' => ['odd']]); // Calculate the amounts of rows with output. $variables['rows'][0]['columns'][0]['attributes'] = new Attribute([ 'colspan' => count($variables['header']), 'class' => ['views-empty'], ]); }
I also see it in the 9.5.x branch code base.
- π¨π¦Canada _randy
Specifically in my case, it's the following that is the issue:
$vars['rows'][$id]['attributes'] = new Attribute(); if ($row_class = $view->style_plugin->getRowClass($id)) { $vars['rows'][$id]['attributes']->addClass($row_class); } $vars['rows'][$id]['attributes']->addClass($col_classes); }
If I comment out the
$vars['rows'][$id]['attributes'] = new Attribute();
and the$vars['rows'][$id]['attributes']->addClass($col_classes);
lines, it works just fine.I haven't had a chance to dig further why it's the row attributes. The only thing I can think of right now is that we're not using fields? We're using display modes on rendered entities. Not sure.
- πΊπΈUnited States shelane
Can you post a screenshot of your views settings for me?
- π¨π¦Canada _randy
I've added 2 screenshots. But I don't think they'll help.
You're 100% right in that this works out of the box (I tried on simplytest.me)
Perhaps this is a Bootstrap5 theme related issue or something in Layout Builder ( https://www.drupal.org/project/bootstrap5 β ).
But it manifests itself first here. I'll have to dig some more.
- πΊπΈUnited States shelane
I installed the Bootstrap5 theme (previously used Barrio for testing) and it worked fine with a similar setup. I don't use Layout Builder, so I'm not sure how I would set that up to test to see if that's associated.
Do you see this happening on any type other than grid?
Out of curiosity, have you tried default responsive grid option? I think it works great and even with Bootstrap, it's my preferred grid.
- π©πͺGermany marc.bau
I think I had this issue when I tried to added a css class via a preprocess function to something. The bad - I deleted the code and cannot remember it exactly.