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.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | output.png | 77.65 KB | shelane |
| #22 | class-settings.png | 30.91 KB | shelane |
| Screenshot [results].png | 47.01 KB | pallas athena | |
| Screenshot [settings].png | 48.12 KB | pallas athena |
Issue fork views_bootstrap-3324207
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
Comment #2
demon326 commentedYou 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.
Comment #3
robbt commentedI 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.
Comment #7
robbt commentedSo 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.
Comment #8
robbt commentedOk 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.
Comment #9
shelaneThis 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.
Comment #15
shelaneComment #16
robbt commentedI'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.
Comment #17
shelaneYou're right. Looks like the changes I made to the template were incorrect. Fix coming shortly...
Comment #19
shelaneIt was the preprocessing that was wrong.
Comment #20
robbt commentedThanks 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.
Comment #21
robbt commentedI 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.
Comment #22
shelaneThe beta4 is working correctly according to labels of the fields. Please check your settings.
Comment #23
robbt commentedYeah 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.