Row class added to all columns

Created on 28 November 2022, almost 2 years ago
Updated 12 June 2024, 5 months ago

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.

πŸ› Bug report
Status

Fixed

Version

5.5

Component

Grid

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States robbt

    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 opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States robbt

    My first MR attempt where I cherry picked code from the other issue above is not working yet. I'll have to dive deeper into the code to determine what further changes are necessary. I'll update here when it's ready for testing.

  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States robbt

    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.

  • Assigned to shelane
  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States shelane

    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.

  • πŸ‡ΊπŸ‡ΈUnited States shelane

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

  • πŸ‡ΊπŸ‡ΈUnited States shelane

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

  • Merge request !19Resolve #3324207 "Grid row class" β†’ (Merged) created by shelane
  • Pipeline finished with Skipped
    6 months ago
    #174456
    • shelane β†’ committed e2144b85 on 5.5.x
      Issue #3324207 by shelane, Pallas Athena: Row class added to all columns
      
  • Issue was unassigned.
  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States shelane
  • πŸ‡ΊπŸ‡ΈUnited States robbt

    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.

  • Assigned to shelane
  • Status changed to Active 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States shelane

    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
      
  • Issue was unassigned.
  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States shelane

    It was the preprocessing that was wrong.

  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States robbt

    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.

  • πŸ‡ΊπŸ‡ΈUnited States robbt

    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.

  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States shelane

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

  • πŸ‡ΊπŸ‡ΈUnited States robbt

    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.

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

Production build 0.71.5 2024