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

Wrap table cell contents instead of CSS truncation #482

Merged
merged 2 commits into from
May 3, 2017

Conversation

iangreenleaf
Copy link
Contributor

I'm not sure what discussion led to this being added since the ticket referenced in ae61171 isn't public. However, I don't like the existing solution because:

  • It doesn't work
  • The Field::Text type already offers truncation with ellipsis, so it duplicates logic to also perform that here. If someone sets a truncation value in their dashboard, they shouldn't have to fiddle with the CSS to have their chosen length respected.

This changes table cells to wrap normally, and to force line breaks on super long strings that don't have a natural break.

This allows table cell contents to wrap to a new line instead of
overflowing the cell's max width, and will also force line breaks on
strings of text that are too long without a natural break.
@tysongach
Copy link
Contributor

@iangreenleaf Can you provide a screenshot where it’s not working and indicate what browser you’re using? I’m not sure I’m seeing the issue in my environment.

Also, can you provide a screenshot of the outcome of this change?

Finally, a couple notes on the CSS:

  • We shouldn’t need to set white-space to normal, as normal is its initial value
  • Per MDN, the word-wrap property has been renamed overflow-wrap, so we need to take that into consideration. We could use Bourbon’s word-wrap mixin, which takes care of this for us.

@iangreenleaf
Copy link
Contributor Author

@tysongach funny, someone edited my entry in the demo app, probably because it was breaking the tables an annoying them. It's hard to show the problem on the demo app because the text fields are being truncated by Rails, but here are some screenshots at just the right width, before and after wrapping:

screenshot_2016-02-22_20-58-47

screenshot_2016-02-22_20-59-09

While testing this, I also discovered that the word-wrap property won't actually help break up long strings, because table layout is super weird. So I'll push an update that just removes the three lines, which will allow normal text with whitespace to wrap, at least. People with long unbroken strings are still on their own.

The word-wrap property doesn't help unless the column width is fixed, so
return this to close to the default.
@nickcharlton
Copy link
Member

Ah hah! I couldn't work out why @tysongach couldn't see this. We truncate text fields by default to 50 characters, so unless you override that you probably won't ever see it.

I can confirm that if you push it up to something along the lines of 150 that it breaks the layout. As it's just removing some CSS, I'm going to merge this as it seems to work well from my testing.

@nickcharlton nickcharlton merged commit 5bc414c into thoughtbot:master May 3, 2017
jonatack pushed a commit to jonatack/administrate that referenced this pull request May 6, 2017
* Wrap table cell contents instead of CSS truncation

This allows table cell contents to wrap to a new line instead of
overflowing the cell's max width, and will also force line breaks on
strings of text that are too long without a natural break.

* Remove table wrapping CSS

The word-wrap property doesn't help unless the column width is fixed, so
return this to close to the default.
jonatack added a commit to jonatack/administrate that referenced this pull request May 6, 2017
* 'master' of https://github.com/thoughtbot/administrate:
  Tweak primary navigation (thoughtbot#861)
  Redesign focus outline styles (thoughtbot#863)
  Localise Dates (thoughtbot#570)
  Wrap unsupported form field notes in proper divs (thoughtbot#515)
  Update customizing_dashboards.md (thoughtbot#568)
  Wrap table cell contents instead of CSS truncation (thoughtbot#482)
  Remove worker from Procfile (thoughtbot#854)
  Remove dependency from ActionMailer (thoughtbot#851)
  Release version 0.6.0.
  Remove delayed_job_active_record dependency (thoughtbot#845)
  use the association includes in the has_many resources as well
  move include work to an association includes
  improve performance for n+1s
iarie pushed a commit to iarie/administrate that referenced this pull request Jun 17, 2017
* Wrap table cell contents instead of CSS truncation

This allows table cell contents to wrap to a new line instead of
overflowing the cell's max width, and will also force line breaks on
strings of text that are too long without a natural break.

* Remove table wrapping CSS

The word-wrap property doesn't help unless the column width is fixed, so
return this to close to the default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants