-
Notifications
You must be signed in to change notification settings - Fork 843
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
Fix word-break in tables on most browsers #1349
Conversation
@cjcenizal Would you mind taking a peak at this PR since you were the one who originally added the word-wrap stuff? @peteharverson Can you check if this fixes your issue? IE11 will still behave poorly because it just doesn't support word-break. |
This reverts commit f457b73.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cchaos Do you think we could update the examples to demonstrate the bug with the original styles, so we can then verify that the new styles fix it?
and using on table cell contents
@cjcenizal & @peteharverson Based on more investigating, I've updated the description of the PR and changed the implementation of the "fix". cc @snide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Nice analysis. Thanks for digging in and explaining everything so clearly. I just had a couple minor suggestions.
@cjcenizal Is this documentation more helpful? |
The problem came about that browser's were breaking on words unnecessarily (in Firefox and IE11). The problem is that neither Firefox nor IE support
word-break: break-word
and so there is a fallback toword-break: break-all
to ensure that long words don't expand past container.What it looked like before:
So this PR changes from using the
word-break: break-word
approach to usingoverflow-wrap: break-word
which is supported by all browsers except for IE11 and behaves just likeword-break
.This is what it looks like now:
Helpers
I've added both a mixin (
euiTextOverflowWrap()
) and CSS utility (.eui-textOverflowWrap
) to handle the ease of usingoverflow-wrap
and the IE fallback.Caveat
There is one big caveat to using
overflow-wrap
. It does not work on items that havedisplay: flex
. Wah wah...Where this becomes an issue is when passing
textOnly: false
toEuiTableRowCell
which removes the containing.euiTableCellContent__text
and places the children as a direct descendent ofeuiTableCellContent
which, guess what?, isdisplay: flex
. 😢So it has to use the
word-break
implementation, meaning it will also use thebreak-all
fallback for Firefox.This usually isn't an issue because the default prop is
textOnly: true
. However,EuiBasicTable
will turn that prop to false if you use therender
function.What it looks like when
textOnly: false
:Firefox will still break on
all
because the containing element is a flex element.I've updated the documentation to try to spell out how to fix this, usually by keeping/adding
textOnly: true
. But another way to combat this is to just wrap the text node with the.eui-textOverflowWrap
utility class.IE11
Blech. Unfortunately, IE11 has no support any type of
break-word
so it will continue to use thebreak-all
fall back.Checklist
[ ] This was checked in mobile[ ] This was checked in dark mode[ ] This was checked for breaking changes and labeled appropriately[ ] Jest tests were updated or added to match the most common scenarios[ ] This was checked against keyboard-only and screenreader scenarios[ ] This required updates to Framer X components