Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column CSS doesn't override row column default css when row-cols-[breakpoint]-[x] is used. #33530

Closed
lacutah opened this issue Mar 31, 2021 · 9 comments · Fixed by #33621
Closed
Labels

Comments

@lacutah
Copy link
Contributor

lacutah commented Mar 31, 2021

OS: Windows 10
Browser: Chrome, Firefox, Edge latest
Version: 5 beta 3

Area: Grid
Apparent Problem: Column CSS doesn't override row column default css when row-cols-[breakpoint]-[x] is used.
My Expectation: Column specific classes should always override row class
Example: CodePen Example

The current order of CSS appears to be wrong:

.row-cols-[x]
.col-[x]
.row-cols-[breakpoint]-[x]
.col-[breakpoint]-[x]

I would expect it to be:

.row-cols-[x]
.row-cols-[breakpoint]-[x]
.col-[x]
.col-[breakpoint]-[x]
@mdo
Copy link
Member

mdo commented Mar 31, 2021

I don't think we designed them to do allow for that override—it was built as either or, not both. Unsure if we wanna take it this direction and allow that.

@lacutah
Copy link
Contributor Author

lacutah commented Mar 31, 2021

The fifth example in the documentation shows it being used that way. And since the example doesn't use a breakpoint it works, so we're getting inconsistent behavior?

https://getbootstrap.com/docs/5.0/layout/grid/#row-columns

<div class="container">
  <div class="row row-cols-4">
    <div class="col">Column</div>
    <div class="col">Column</div>
    <div class="col-6">Column</div>
    <div class="col">Column</div>
  </div>
</div>

@mdo
Copy link
Member

mdo commented Mar 31, 2021

Oh shit, my bad. And I wrote the thing lol. Let's fix it!

@lacutah
Copy link
Contributor Author

lacutah commented Mar 31, 2021

I did notice that the documentation doesn't explicitly say cols should overwrite the row "shortcuts" - but it seems the documentation should be made explicitly clear (and it follows order of specificity in my head!) if this is fixed.

In the existing documentation the closest I could find:
Whereas normal .col-* classes apply to the individual columns (e.g., .col-md-4), the row columns classes are set on the parent .row as a shortcut.

My first bug here - but been (consuming) bootstrap for awhile - wasn't sure if this was a bug or if I wasn't understanding or if there was some other reason it wasn't working consistently.

@ffoodd
Copy link
Member

ffoodd commented Apr 1, 2021

There's at least some confusion in the docs, I agree.

The part you're quoting implicitly talks about specificity though: targetting the element itself (single class) or the parent (at least a class and a selector). The latter wins.

Needs to be made clearer in the docs, not sure either those should work together.

@lacutah
Copy link
Contributor Author

lacutah commented Apr 13, 2021

I made a change in the order the cols and row-cols is compiled and submitted pull request #33621 along with a change to the row-cols documentation.

The pull request is admittedly opinionated and makes it official that row-cols isn't a(n inconsistent) shortcut, it's a default for columns in the row that can be overridden at the column level.

I'm a newbie at contributing scss changes, wasn't sure how to test besides npm run test and making sure the examples still worked as before. scss testing / node is something I don't touch unless something is broken...

@lacutah
Copy link
Contributor Author

lacutah commented May 4, 2021

Not sure where you're all focused on, looks like this stalled out - I'm still happy to help out if more changes needed - see my comments in the proposed pull request.

@danielkauffman
Copy link

@lacutah Is this issue still fixed after #34341?

@lacutah
Copy link
Contributor Author

lacutah commented Jun 24, 2021

@danielkauffman - it breaks, example here: https://codepen.io/Lacutah/pen/mdWNPyR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants