This is a follow up to issue 2642592.

I'm having similar issues with header width on pages where the Add new comment form is displayed.

But I now think this has nothing to do with the Comment form (see fix in related issue) because the width of the header varies quite a bit from page to page (articles where comments are enabled).

The varying header's width appears to be dependent on long strings i.e. URLs that do not wrap properly. Here are a few examples.

  1. /admin/config/regional/translate/translate
  2. /admin/commerce/config/payment-methods/manage/commerce_payment_commerce_stripe)
  3. /sites/all/themes/mytheme/js/toggler.js

Any ideas how to solve this?

Comments

bisonbleu created an issue. See original summary.

bisonbleu’s picture

Just to be clear, if the string has white spaces or hyphens (i.e. '-') wrap works.

But a string such as the following won't wrap and breaks the viewport when the system tries to fit that string on one line while in portrait mode on a mobile.

/aaaaa/bbbbb/ccccc/ddddd/eeeee/fffff/ggggg/hhhhh/iiiii

bisonbleu’s picture

StatusFileSize
new56.97 KB

And here's a test done on https://simplytest.me/

long string breaks header image

bisonbleu’s picture

A partial solution: adding inline CSS, for example: word-wrap: break-word;.

But I'm wondering where the best place is to fix this?

  • Does it make sense for the theme to fix this out-of-the-box and in broad fashion?
  • Or is this kind of issue best solved with custom CSS on a case by case basis?
joelpittet’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)
StatusFileSize
new49.49 KB

@bisonbleu Sorry I can't reproduce this with the latest dev release so I've got to assume it's been fixed already.

bisonbleu’s picture

Status: Closed (cannot reproduce) » Active

On my website, I am using 7.x-4.2+13-dev - which is the latest dev. I just loaded branch 7.x-4.x on simplytest.me. I believe that is the latest dev, right?

In both cases when viewing the test article on an iPhone 6 using mobile Safari, the string /aaaaa/bbbbb/ccccc/ddddd/eeeee/fffff/ggggg/hhhhh/iiiii doesn't wrap as shown in the capture in #3.

I'm guessing the result you got was by squeezing your browser, right? I get properly wrapped string when I squeeze my browser (FF). But the browser is not telling the whole truth.

Can you please repeat your test on simplytest.me and then visit that page with your smart phone? I'm pretty sure you will see something resembling the capture in #3.

joelpittet’s picture

I see what you are seeing with chrome.

Couple things I'd do but not sure if they are generally good.

I would remove , maximum-scale=1.0, user-scalable=0 from the viewport meta

It should probably just be:
<meta name="viewport" content="width=device-width,initial-scale=1">

And I'd scroll content if it didn't wrap with something like

#content { overflow-x: auto; }

That way the user can pinch zoom still, the text will wrap if it can and if it can't it will allow scroll and not break the container.

Does that work?

bisonbleu’s picture

Applying both of your suggestions works: the container is no longer broken and where long unbreakable strings occur, the viewport scrolls horizontally.

I agree with you when you write not sure if they are generally good. Although this fix is much better than a broken container, I don't feel completely comfortable with this solution because it appears to be somewhat fragile?

Getting the wrap to properly work would of course be ideal and more scalable as far as future releases are concerned.

Thanks very much for your help on this!

joelpittet’s picture

It's not fragile at all. It's just a particular approach that I use most of the time.

bisonbleu’s picture

Ok, not fragile then; that's good. I misread your not sure if they are generally good.

By fragile I was underlying the fact that the proposed solution doesn't directly fix the non-wrapping strings but it does stop them from breaking the container. So damages are 'contained', which is great.

Now does it make sense to build those 2 changes into the code of Basic ? With a bit of guidance, I'll help with the patch.

leahtard’s picture

There is also the option to set the word wrap with CSS. There is also a Bourbon helper for this:

.class-name
  @include word-wrap

Cheers, Leah

joelpittet’s picture

@bisonbleu was leaving room if someone had a better or alternative solution;)

joelpittet’s picture

@bisonbleu the viewport change is actually not related to this patch and may not be needed for the fix I just noticed that should be changed. I'll do that in a separate issue. Just the overflow-x should be done here if that is the best solution.

bisonbleu’s picture

Thanks Leah, that's a nice addition to the mix.

I've played with @include word-wrap(normal) and @include word-wrap(break-word). The former does nothing for long unbreakable strings. The latter does but the result isn't always ideal.

Do you know of a way to break on predefined characters e.g. '/' ?

p.s. Thanks for the update Joel.

joelpittet’s picture

breaking on characters could help eliviate the symtoms but not the problem it seems to me.
At some point you may run into: supercalifragilisticexpialidocious

bisonbleu’s picture

lol, that's a nice word :-). Adding link to similar issue for Bartik in D8.

bisonbleu’s picture

In the end, I realize that the theme, any theme, is unlikely to be able to solve this problem out-of-the-box - which is a complex one at that.

So what's the solution? I would say: adopting an appropriate strategy for dealing with the occurrence of long strings.

In my use-case, the long strings that are troublesome are usually URLs (absolute, relative or partial) or function names e.g. theme_commerce_price_formatted_components().

Here are 3 elements of a sound strategy.

With just these 3 elements, I'm able to solve most of my issues with one line of CSS. Not that css properties such as word-wrap or hyphens don't work - they do. But I would venture to say that that represents more work than coming up with a simple strategy. I would keep those for extreme and very bothersome cases that cannot be solved by strategy alone.

In the end, it all boils down to design, mobile-first design.

awasson’s picture

Status: Active » Closed (outdated)

Thanks for all the work on this back in the day.

I'm closing this as outdated because Drupal 7 is no more.

Cheers,
Andrew