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

Enable wrapping for elements in modal-footer #25103

Merged
merged 2 commits into from Aug 16, 2019

Conversation

MartijnCuppens
Copy link
Member

@MartijnCuppens MartijnCuppens commented Dec 28, 2017

Fixes #24800.

> :not(:last-child) { margin-right: .25rem; }
// Place margin between footer elements
// stylelint-disable selector-max-universal
> * {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a no-go for me—we avoid universal selectors like this whenever possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdo Why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MartijnCuppens this PR explains it #25165

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we should use classes as much as possible. But in this case you don't know which elements are going to be placed in the .modal-footer.

Also right now the following code is used to place margins between the elements:

  // Easily place margin between footer elements
  > :not(:first-child) { margin-left: .25rem; }
  > :not(:last-child) { margin-right: .25rem; }

Imo this isn't more dogmatic as the use of the universal selector.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh word, hmm. Those are also universal selectors since they'll match every elements first before limiting to last/first children. Both are bad generally speaking because they take much longer for browsers to parse and apply.

I wonder if a mix of these existing styles and a .modal-footer-item would work? Or perhaps we just recommend spacing utils? A single universe selector is better than two though, too. Hmm...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With spacing utils, there are some responsive issues (spacing between wrapped elements). Providing the .modal-footer-item class would be the best solution if we want to prevent the use of the universal selector. Downside: It must be added to all children of the .modal-footer and that would break all existing implementations of the modal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdo Have you made your mind up about this?

@XhmikosR

This comment has been minimized.

@MartijnCuppens

This comment has been minimized.

@MartijnCuppens
Copy link
Member Author

We can now use the negative margin utility classes to fix this, but then still the 2 universal selectors (.modal-footer > :not(:first-child) & .modal-footer > :not(:last-child)) will remain, so it might be better to use the * here so that we only have one poorly performing selector instead of two. I've added a warning about the universal selector usage in this PR.

@mdo, your call if we continue with this.

@MartijnCuppens MartijnCuppens added this to Inbox in v4.2 via automation Nov 5, 2018
@XhmikosR XhmikosR requested a review from a team as a code owner November 5, 2018 07:55
@XhmikosR XhmikosR moved this from Inbox to Needs review in v4.2 Nov 18, 2018
@XhmikosR XhmikosR removed this from Needs review in v4.2 Dec 10, 2018
@XhmikosR XhmikosR changed the base branch from v4-dev to master March 13, 2019 17:32
@MartijnCuppens MartijnCuppens added this to Inbox in v4.4.0 via automation Aug 9, 2019
@MartijnCuppens MartijnCuppens added this to Inbox in v5 via automation Aug 9, 2019
@MartijnCuppens
Copy link
Member Author

@twbs/css-review, this one is an older PR from me, but I think it's still relevant so I've added it to the v4.4.0 project

@mdo
Copy link
Member

mdo commented Aug 15, 2019

Sorry @MartijnCuppens! Looking at this again, my concern here is that this could cause unintended side effects for folks who have put other items in their .modal-footer (like text, custom elements, etc).

Should we instead limit the selector to > .btn?

@MartijnCuppens
Copy link
Member Author

No problem, @mdo! We did already target all elements (not only .btn) with > :not(:first-child) and > :not(:last-child), so in this case it might be safer to use the *.

Copy link
Member

@mdo mdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, I'm dumb. This looks good then!

v5 automation moved this from Inbox to Approved Aug 15, 2019
@XhmikosR XhmikosR merged commit bbbda68 into twbs:master Aug 16, 2019
v5 automation moved this from Approved to Shipped Aug 16, 2019
@XhmikosR XhmikosR moved this from Inbox to Shipped in v4.4.0 Aug 16, 2019
@MartijnCuppens MartijnCuppens deleted the modal-footer-fix branch August 17, 2019 10:11
@anatolebeuzon
Copy link

Thanks for fixing this! 👏 👏

lucanos pushed a commit to lucanos/bootstrap that referenced this pull request Oct 27, 2019
@karlsve
Copy link

karlsve commented Jan 10, 2020

Sorry for resurrecting the dead but I was just wondering if anyone had thought about how to handle multiple paddings with this fix?

customizations.scss

$modal-inner-padding: 5px 4px; // This will break the style as the resulting css will be concatenated

@MartijnCuppens
Copy link
Member Author

@karlsve, that won't be possible with the current implementation, but could be fixed by splitting the variable into $modal-inner-padding-x and $modal-inner-padding-y variables. You may open a PR for this.

@karlsve
Copy link

karlsve commented Jan 10, 2020

As the $modal-inner-padding is only used by the .modal-body to actually define all its paddings, shouldn't this be using different variables anyways if there are calculations done?
This would cause developers to define the same value five times in the worst case, which isn't good either.

Another way would be to somehow force the calculation to be done on all elements of a list of values. I have to admit that I am not sure if SASS / SCSS supports this in any way.

It also seems to me like more people should be experiencing this issue as my team cannot be the only one which set the $modal-inner-padding like this in bootstrap 4.3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v4.4.0
  
Shipped
v5
  
Shipped
Development

Successfully merging this pull request may close these issues.

Long buttons in modal-footer don't start on a new line
6 participants