First of all: Thanks for all your work!

When I add a class to the Bootstrap Grid row this class is added to all columns instead of the row. I tried to clear the cache and reinstall the module, but without luck. Please, see my added screenshots.

Command icon 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

Pallas Athena created an issue. See original summary.

demon326’s picture

You could copy views-bootstrap-grid.html.twig to your theme folder, 'hardcode' the classes, rename it to views-bootstrap-grid--[views_displayname].html.twig and clear caches.

robbt’s picture

I can confirm that this indeed is a problem with the current 5.5.alpha code.

I found that applying the patch to allow the customization of the number of columns here - https://www.drupal.org/project/views_bootstrap/issues/3120960 fixed this problem.

I haven't delved deeper into why yet.

I realized that the approach I have taken utilizes row columns to make the grid responsive rather than changing the width of the individual columns and the overall container.

I'll try to compare the code with the patch and the default code and see if I can provide a simpler patch to fix this behavior but wanted to share my findings.

robbt’s picture

So the MR is incomplete, it adds a row wrapper class which actually replaces the row CSS.

The bug here is that the language suggests that each row gets classes when it actually is adding those classes to the columns as described in the bug report. The code itself says its iterating and outputting rows but they're actually the columns so that is confusing.

In theory the row class should be doing what the wrapper class code I grabbed from the other issue but it should be sure to prepend the row class.

I'll work on rewriting this so it solves the problems as described.

robbt’s picture

Version: 5.5.0-alpha1 » 5.5.x-dev
Status: Active » Needs review

Ok so I figured out the issue is that in Views a row seems to be every column/item. Whereas in bootstrap a row is essentially a wrapper for a number of columns. So I just disabled the utilization of the built-in row class for the Bootstrap Grid and it appears to work and will allow you to utilize row-column classes to supercede the built-in columns.

The only reason I could think of not merging this is that it would remove the ability to apply classes to columns via the UI, but doing that would require overriding the built-in views code and language so that it says column vs. row because the terminology is confusing and contradictory.

Happy to have people review this.

shelane’s picture

Assigned: Unassigned » shelane
Status: Needs review » Needs work

This is close, but not quite the implementation that I do for other items. I will finish this up and get it merged. Thanks for your contribution.

shelane changed the visibility of the branch 3324207-grid-row-class to hidden.

shelane changed the visibility of the branch 3324207-grid-row-class to active.

  • shelane committed e2144b85 on 5.5.x
    Issue #3324207 by shelane, Pallas Athena: Row class added to all columns
    
shelane’s picture

Assigned: shelane » Unassigned
Status: Needs work » Fixed
robbt’s picture

I'm trying this code and it doesn't appear to work to provide the class to the row. I'll be testing when I applied to a test server I get an error - User error: "attributes" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php).

And it looks like the row class code is applied to the columns and the new form is also applied to the column.
I see it added Custom column class which is added to every column as one would want and what was missing from my contribution but Grid row custom class also gets applied to the individual column divs and not to the entire row as was the intended behavior that my MR added.

I'll tinker around with it further but thought I'd share my feedback thus far.

shelane’s picture

Assigned: Unassigned » shelane
Status: Fixed » Active

You're right. Looks like the changes I made to the template were incorrect. Fix coming shortly...

  • shelane committed b6014a57 on 5.5.x
    Issue #3324207 by shelane, demon326: Row class added to all columns
    
shelane’s picture

Assigned: shelane » Unassigned
Status: Active » Fixed

It was the preprocessing that was wrong.

robbt’s picture

Status: Fixed » Needs work

Thanks for the quick response. I pulled the latest dev code and it was still providing me with the errors and not quite working as intended.

User error: "attributes" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php).

And it isn't applying the row classes from Grid row custom class to the row div but instead it is now adding the row class to the top wrapper div that contains the view id vs. the next nested div (which is the row div).

Also now the columns aren't receiving the custom class from the Custom column class field under the bootstrap grid settings (which they were before this latest commit).

So I think additional work is needed. I'm not sure where the render array key errors is coming in but maybe attributes doesn't exist in the render key according to the error.

robbt’s picture

I think I found part of the problem. A newer commit - https://git.drupalcode.org/project/views_bootstrap/-/commit/cf14a0ac12fc... - seems to have reverted the twig file templates/views-bootstrap-grid.html.twig that was modified in the previous MR - https://git.drupalcode.org/project/views_bootstrap/-/commit/e2144b8546f1...

So I'll see if I can come up with a working MR based upon the latest branch.

shelane’s picture

Status: Needs work » Fixed
StatusFileSize
new30.91 KB
new77.65 KB

settings

output

The beta4 is working correctly according to labels of the fields. Please check your settings.

robbt’s picture

Yeah sorry about the confusion. I discovered/remembered after a fair amount of troubleshooting that I had overwritten the twig template for the view in order to add some markup. So that was what was causing the issue on my part. Thanks and sorry for the confusion.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.