Problem/Motivation

Long strings within comments break the layout of the page.

How to replicate:

Make a comment with very long line (like ______________________) or a long url

It will break the layout of the comment boxes.

Example screenshots:


 

 

 

Current code at HEAD for the .comment__content wrapper

.comment__content {
  position: relative;
  display: table-cell;
  padding: 10px 25px 10px 25px;
  vertical-align: top;
  width: 100%;
  border: 1px solid #d3d7d9;
  font-size: 0.929em;
  line-height: 1.6;
}

Proposed resolution

Add a fix so that long strings wrap within the .comment__content container.

Remaining tasks

Write a patch
Visual review - Post screenshots
Code review

User interface changes

Fixes a broken page layout caused by long strings in comments.

API changes

none

Data model changes

none

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because strings in comments can break the page layout of Bartik - especially on mobile
Issue priority Normal because it is a visual bug with Bartik only.
Unfrozen changes Unfrozen because it only changes CSS.
Prioritized changes The main goal of this issue is usability. Currently if someone adds a long URL to a comment the site layout breaks on smaller screens.
Disruption Non-disruptive
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

corbacho’s picture

I removed that fix because wasn't working in Google Chrome.

tatianataylor’s picture

Corbacho,

Would you be able to say which .inc file or module was this code at? I am trying to find where is the issue in the code first so maybe I can create a patch.

Thanks,
T.

kpun’s picture

Assigned: Unassigned » kpun
Issue summary: View changes
kpun’s picture

Status: Active » Needs review
FileSize
1.12 KB

@Corbacho i think the changes you have mentioned should be made in the .comment section .

corbacho’s picture

Version: 7.x-dev » 8.1.x-dev
Issue tags: +CSS novice
FileSize
48.33 KB

Hi kpun, I can't replicate anymore the bug in Drupal 7. It seems it has been fixed with the solution you are proposing.
btw, The patch contains changes to the menu.module that shouldn't be there.

I was going to close the issue... but I can replicate the problem in Drupal 8 (changing issue metadata)

screenshot

Could you add these 3 lines to Drupal 8 ? I tested on Chrome devtools, and it worked.

.comment {
    display: table;
    table-layout: fixed;
    width: 100%;
}
corbacho’s picture

Issue summary: View changes
kpun’s picture

done

Status: Needs review » Needs work

The last submitted patch, 7: Word-wrap_comments_in_Bartik.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: Word-wrap_comments_in_Bartik.patch, failed testing.

kpun’s picture

kpun’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: Word-wrap_comments_in_Bartik_0.patch, failed testing.

kpun’s picture

corbacho could you please tell why the patch does not work ? I am not able to figure it out.

corbacho’s picture

Status: Needs work » Needs review

Thanks for the patch!
it seems a random error, not related to the patch. Let's try again

Status: Needs review » Needs work

The last submitted patch, 11: Word-wrap_comments_in_Bartik_0.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: Word-wrap_comments_in_Bartik_0.patch, failed testing.

corbacho’s picture

me not understand

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: Word-wrap_comments_in_Bartik_0.patch, failed testing.

corbacho’s picture

Status: Needs work » Needs review
FileSize
379 bytes

let's try re-uploading patch #7 from kpun (credit to him)

Status: Needs review » Needs work

The last submitted patch, 23: Word-wrap_comments_in_Bartik-1085472-7.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: Word-wrap_comments_in_Bartik-1085472-7.patch, failed testing.

emma.maria’s picture

Ah! The reason why it is not working is that style.css does not exist in Bartik in D8. The CSS now has a SMACSS style architecture so the patch needs to affect the new files.

emma.maria’s picture

Issue summary: View changes
FileSize
59.96 KB

I have also found this issue within a Forum table also...

corbacho’s picture

:O mistery solved!
I'll ping kpun if he wants to finish the job

rudraram’s picture

FileSize
54.29 KB

@emma.maria @corbacho This issue looks file with the comment section but exists with the forums table. Attaching comment section screenshot.

word-wrap

emma.maria’s picture

Assigned: kpun » Unassigned
Issue tags: -CSS novice +CSS, +frontend, +Novice

The issue posted in #28 is different to the original issue. The original issue is with no word spacing.

I will have a test and maybe post a seperate issue.

Also unassigning for now as @kpun has not been active on this issue for a month and we should open it up again.

emma.maria’s picture

Let's ignore the Forum table issue within this issue, it's not the same.

The issue here is that if you add a long string to a comment, it will continue to push the comment out of the page container because of this style. This is particularly needed for small mobile widths as the space for comments is so small...
 

 
I tried using the solution posted in the IS and the previous patch to the current codebase but it caused further regressions and did not help :-(
 

 

 
The comments code has been refactored since this bug was discovered. So we need a new CSS solution!
The current code on the comment content is...

.comment__content {
  position: relative;
  display: table-cell;
  padding: 10px 25px 10px 25px;
  vertical-align: top;
  width: 100%;
  border: 1px solid #d3d7d9;
  font-size: 0.929em;
  line-height: 1.6;
}

PS. word-wrap: break-word which is set on the body does not work on mobile devices for some reason.

emma.maria’s picture

I've updated the Issue summary.

emma.maria’s picture

Title: Word-wrap comments in Bartik » Long strings within comments break Bartik's page layout.
rudraram’s picture

FileSize
396 bytes

As word-wrap: break-word is not working on mobile devices I have used word-break: break-all just for the .comment__wrapper. I don't know if this is ok but it works. Patch uploaded

rudraram’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 35: long-comments-1085472-35.patch, failed testing.

rudraram’s picture

@emma.maria The below image from your upload shows 8.0.x and the version for this issue is mentioned as 8.1.x-dev.
mobile

emma.maria’s picture

Version: 8.1.x-dev » 8.0.x-dev
Status: Needs work » Needs review

Ok thanks, I've changed the version to 8.0.x I would like this fixed ASAP.

rudraram’s picture

@emma.maria Thoughts on #35 ?

briandev’s picture

Maybe we can set the "break-word" to only apply to anchor links within comments:

.comment__content a {
  word-break: break-all;
}
emma.maria’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
66.18 KB
69.44 KB
65.1 KB
122.93 KB

Thanks @rudraram for the patch!

I can confirm that word-wrap has no effect but word-break fixes the visual issue.

I checked word-break on caniuse.com and it has pretty good support.
Namely the word-break: break-word combination has this description...

Chrome, Safari and other WebKit/Blink browsers also support the unofficial break-word value which is treated like word-wrap: break-word.

Therefore I am happy with this solution!

Screenshots:

Chrome

Firefox

Safari

IE9

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 35: long-comments-1085472-35.patch, failed testing.

martins.kajins’s picture

Status: Needs work » Needs review
FileSize
406 bytes

emma.maria’s picture

@martins.kajins thanks for your patch. However your solution you provided is different from the patch that was tested, solved the issue and was set to RTBC in #35.

The patch in #35 was set to red by the testbot and still cleanly applies. It is retesting now and I will set this back to RTBC based on #35 again.

emma.maria’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
396 bytes

To avoid confusion with what patch to commit here is a straight re-upload of @rudraram's patch from #35.

Setting this issue back to RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed eef4588 on 8.0.x
    Issue #1085472 by kpun, emma.maria, corbacho, rudraram, martins.kajins,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

paintingguy’s picture

Sorry if I am duplicating the Q&A but I'm having this issue right now with D8 current release. Is there a fix in this post ? Thanks.

paintingguy’s picture

Ah, I tried this and it worked:

diff --git a/core/themes/bartik/css/components/comments.css b/core/themes/bartik/css/components/comments.css
index 30e1be8..03bbfd1 100644
--- a/core/themes/bartik/css/components/comments.css
+++ b/core/themes/bartik/css/components/comments.css
@@ -61,6 +61,7 @@

   border: 1px solid #d3d7d9;
   font-size: 0.929em;
   line-height: 1.6;
+  word-break: break-all;
 }
 
 .comment__content:before {
jonathanshaw’s picture

I wonder if this issue has introduced a regression: #2679126: Words break unnecessarilly at end of line in forum topic replies.

Perhaps #42 above offers a direction.

jonathanshaw’s picture

Version: 8.0.x-dev » 9.x-dev

An alternative solution to this issue is now proposed in #2679126

Version: 9.x-dev » 9.0.x-dev

The 9.0.x branch will open for development soon, and the placeholder 9.x branch should no longer be used. Only issues that require a new major version should be filed against 9.0.x (for example, removing deprecated code or updating dependency major versions). New developments and disruptive changes that are allowed in a minor version should be filed against 8.9.x, and significant new features will be moved to 9.1.x at committer discretion. For more information see the Allowed changes during the Drupal 8 and 9 release cycles and the Drupal 9.0.0 release plan.