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

text-break class is not working anymore from Bootstrap 4.4.1 to 4.5.0 #30803

Closed
marcosandri-dev opened this issue May 13, 2020 · 14 comments · Fixed by #30932
Closed

text-break class is not working anymore from Bootstrap 4.4.1 to 4.5.0 #30803

marcosandri-dev opened this issue May 13, 2020 · 14 comments · Fixed by #30932

Comments

@marcosandri-dev
Copy link

The workaround I have found for this is to put back the word-break: break-word in the text-break class, like it was in the previous versions;

@mdo
Copy link
Member

mdo commented May 13, 2020

Confirmed:

Screen Shot 2020-05-13 at 7 54 18 AM

@mdo
Copy link
Member

mdo commented May 13, 2020

Most investigation shows this works with block level elements, but when flexbox is introduced, it falls apart. See https://codepen.io/emdeoh/pen/dyYjwoO?editors=1100.

@mdo
Copy link
Member

mdo commented May 13, 2020

@florianlacreuse
Copy link
Contributor

By default, flex items won’t shrink below their minimum content size. Setting min-width: 0 on concerned flex items fix the text break. See https://codepen.io/florianlacreuse/pen/ZEbMGda (FWIW)

@mdo
Copy link
Member

mdo commented May 14, 2020

Oh yeah, didn't think about that at all. Do we ship this as a fix, or tell folks to use min-width: 0 (and possibly provide a utility for that)? Feels like we do both: ship this and add some docs around this behavior.

@MartijnCuppens
Copy link
Member

Adding the min-width will be quite hard to implement with our utility API I guess

@mdo
Copy link
Member

mdo commented May 14, 2020

@MartijnCuppens You okay then with shipping an update to bring back word-break: break-word on the utility and a mention about this flexbox issue in our docs? And, likely for v4 and v5?

@nicolomonili
Copy link

nicolomonili commented May 18, 2020

Same issue here (MacOS / Google Chrome 81.0.4044.138 / Bootstrap 4.5)
An element with class text-break no longer works properly if it is placed inside an element with the class d-flex.

min-width:0 fix the problem for now

@florianlacreuse
Copy link
Contributor

@mdo @MartijnCuppens Be careful, as I said in this issue word-break: break-word is deprecated, just for the record.

@nicolomonili Thanks, see the anwser about the minimum content size behavior on flex items.

@nicolomonili
Copy link

nicolomonili commented May 18, 2020

The problem is also present with tables / td, but in this case the problem persists even adding min-width:0. Try to add class="text-break" on a <td> with a long text.

Ok with 4.4 https://getbootstrap.com/docs/4.4/content/tables/#responsive-tables
Schermata 2020-05-18 alle 13 58 33

Not ok with 4.5 https://getbootstrap.com/docs/4.5/content/tables/#responsive-tables
Schermata 2020-05-18 alle 13 59 01

@florianlacreuse
Copy link
Contributor

In this case table-layout: fixed; makes things work fine. But yeah less than ideal. I will be OK with any decision, even if we need to go back to word-break property.

@mdo
Copy link
Member

mdo commented May 30, 2020

Looking at this Codepen I made a couple weeks ago again, it seems like a browser bug or unintentional behavior that word-break: word-wrap would have different behavior than word-wrap: break-word/overflow-wrap: break-word with flex containers. While the former is deprecated, it fixes some weird behaviors, so I'm in favor of bringing it back.

bryan-brancotte added a commit to cpina/django-crispy-forms that referenced this issue Jun 8, 2020
smithdc1 pushed a commit to django-crispy-forms/django-crispy-forms that referenced this issue Jun 17, 2020
#1032)

* File field Bootstrap4: avoids long file names overflowing outside the label

* Using h-auto to prevent vertical overflow, and text-break to prevent horizontal overflow

* Fixing text-break. cf twbs/bootstrap#30803

* Using text-truncate to prevent long file name overflow

* refactor test to follow field_file.html evolution

* compliance with Black

* fixing regression, checkbox must float right

partial rollback of 8aaed1b

Co-authored-by: Bryan Brancotte <bryan.brancotte@pasteur.fr>
@ihorzenich
Copy link

@mdo @XhmikosR This fix was backported to v4 with without keeping word-wrap: break-word for IE and Edge Legacy (see: #29319)

There's no issue in v5:

.text-break {
  word-wrap: break-word !important;
  word-break: break-word !important;
}

But in v4 we have word-break which didn't support break-word value in IE and Edge Legacy (comment in source is wrong) and overflow-wrap which is absent in IE/Edge Legacy (it's modern replace for word-wrap):

.text-break {
  word-break: break-word !important; // IE & < Edge 18
  overflow-wrap: break-word !important;
}

So .text-break don't work in IE/Edge Legacy in v4 now.
I fixed it by sync .text-break in v4 with v5 and created PR for that: #31727

@ihorzenich
Copy link

ihorzenich commented Sep 25, 2020

Unfortunately .text-break don't work inside flex containers in IE/Edge Legacy even with this fix.
This happens because it don't support break-word value for word-break property.

In modern browsers word-break: break-word treated as word-break: normal+overflow-wrap: anywhere (which means it work inside flex), but in IE/Edge Legacy we only have word-wrap: break-word supported which has the same effect as overflow-wrap: break-word (which didn't work inside flex).

To fix it we need to define a width for the container.
See: https://stackoverflow.com/questions/35111090/text-in-a-flex-container-doesnt-wrap-in-ie11#answer-35113633
width: 100% works both in IE and Edge Legacy,
flex-basis: 100% and flex: 1` will work only in IE11, not in Edge Legacy.

Demo: https://codepen.io/ihorzenich/pen/LYNqqPJ

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

Successfully merging a pull request may close this issue.

6 participants