Suggested commit message:

git commit -m 'Issue #2661128 by meichr, kannan@kiluvai.com, Pnoi, emma.maria: Bartik - Responsive menu-toggle shows up in show mode after switching from mobile to pad or desktop display'

Bartik theme has a responsible primary navigation built in with three display sizes for mobile, pad and desktop.
In mobile display either a "Show" or a "Hide" menu-toggle bar are being provided to show or hide the primary menu. These two bars are not needed in pad and desktop navigation display as the primary menu is always visible in those display sizes.

Brief steps to reproduce:

  1. Start on a small screen (Width < 461 px)
  2. Show the primary menu by using the toggle
  3. Enter a breakpoint 461px or wider by resizing browser, rotating device, etc.

The expected behaviour is that the menu toggle will not be displayed on wider viewports but it is still displayed if the menu was toggled open on a smaller viewport.

On small screens and tablets this can be a problem with different pixel widths for portrait and landscape display and when resizing windows on desktop.

Reproduction
I've used Firefox with built-in tool 'Responsive design view' to create screen shots using the mobile format 360x640px, but the bug hits anytime when the Bartik breakpoint of 461px is crossed by switching from portrait to landscape orientation or increasing the width of a browser window after the mobile menu has been opened.
You can reproduce the error easily on a freshly installed Drupal 8.1.x by the following steps:

  1. Step - Open firefox, turn on the 'Responsive design view' in the 'Tools=>Developer' menu, switch to 360x640px format (portrait) and open the freshly installed D8.1.x test site.
    Step 1
  2. Step - Click on the toggle-menu sign to open the menu (consisting only of the 'Home' link)
    Step 2
  3. Step - Click on the orientation button of the 'Responsive design view' tool to switch from portrait to landscape orientation
    • Without the patch installed, you still see the "Hide - Main navigation" bar, although Bartik should have hidden it now.
      Step 3 - without patch
    • With the patch installed, you will not see the "Hide - Main navigation" bar, as it is not needed in this display size of the responsive theme.
      Step 3 - with patch

Solution
Apply patch of first comment in this issue. Please make sure to clear the cache after applying the patch ('drush cr' or via UI).

CommentFileSizeAuthor
#32 drupal-bartik-menu-toggle-show-visible-in-pad-and-desktop-display-2661128-32-8.2.x-dev.patch663 bytesmeichr
#32 interdiff-2661128-22-32.txt629 bytesmeichr
#25 firefox-before.jpg41.97 KBPnoia
#25 firefox-after.jpg33.88 KBPnoia
#25 chrome-before.jpg43.03 KBPnoia
#25 chrome-after.jpg39.55 KBPnoia
#22 drupal-bartik-menu-toggle-show-visible-in-pad-and-desktop-display-2661128-22-8.1.x-dev.patch666 bytesmeichr
#18 drupal-bartik-menu-toggle-show-visible-in-pad-and-desktop-display-2661128-18-8.1.x-dev.patch700 bytesmeichr
#2 bartik-menu-toggle-show-visible-in-pad-and-desktop-display-2661128-1.patch1.06 KBmeichr
#6 bartik-desktop-chrome.png218.36 KBkannan@kiluvai.com
#6 bartik-desktop-firefox.png122.18 KBkannan@kiluvai.com
#6 bartik-mobile-chrome.png216.2 KBkannan@kiluvai.com
#6 bartik=mobile-firefox.png185.34 KBkannan@kiluvai.com
#6 bartik-pad-chrome.png226.74 KBkannan@kiluvai.com
#6 bartik-pad-firefox.png183.87 KBkannan@kiluvai.com
#7 Step3-with-patch--Mobile-360x640--turn-mobile-to-landscape-orientation.png106.48 KBmeichr
#7 Step3-without-patch--Mobile-360x640--turn-mobile-to-landscape-orientation.png112.97 KBmeichr
#7 Step2--Mobile-360x640-portrait--touch-menu-toggle-to-open-menu.png108.67 KBmeichr
#7 Step1--Mobile-360x640--hold-mobile-in-portrait-orientation.png159.78 KBmeichr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

meichr created an issue. See original summary.

meichr’s picture

Here is a patch which adds two CSS selectors for hiding the "Hide - Main navigation" bar including the hamburger icon in pad and desktop display size.

dcrocks’s picture

Status: Active » Needs review

test it

kannan@kiluvai.com’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +drupalconasia2016

Tested this in Chrome and firefox it was working good as specified, Test is done using developer toolbar.

Steps done for testing

  1. Applied patch
  2. resized for mobile -> show navigation visible -> clicked on show navigation -> menu item visible
  3. resized for pad -> hide navigation was hidden
  4. resized for desktop -> menu item visible normally
star-szr’s picture

Assigned: Unassigned » emma.maria
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs screenshots

Thanks, assigning to @emma.maria to take a look. This could use screenshots as well.

kannan@kiluvai.com’s picture

meichr’s picture

Thanks to DrupalConAsia2016, kannan@kiluvai.com and Cottser for evaluating this.

The error is still there in Drupal 8.1.x (March 19, 2016) and the patch of #1 still applies to Drupal 8.1.x without warnings or errors.

I hope the attached screenshots explain the problem and its reproduction more easily.

Edit: Moved the illustrated reproduction description to the top.

meichr’s picture

Issue summary: View changes
meichr’s picture

Title: Bartik - Responsive menu-toggle shows up in pad and desktop display in show mode » Bartik - Responsive menu-toggle shows up in in show mode after switching from mobile to pad or desktop display
Assigned: emma.maria » Unassigned

Trying to clarify the title.
It appears emma.maria has been responsible during DrupalConAsia2016 sprints only, I hope I'm not bold removing her from the assignment. Please correct me and apologize, if I'm wrong.

meichr’s picture

Title: Bartik - Responsive menu-toggle shows up in in show mode after switching from mobile to pad or desktop display » Bartik - Responsive menu-toggle shows up in show mode after switching from mobile to pad or desktop display

Correcting title typo.

meichr’s picture

Got it! emma.maria is one of the maintainers of the D8 core Bartik theme. Can't assign it back to her by myself, sorry.

meichr’s picture

Issue summary: View changes

Bug is also present in current Drupal-8.2.x-dev and can be corrected by the patch in #1 as well.

emma.maria’s picture

Assigned: Unassigned » emma.maria

The more pressing bug that I see here is that the text...

"Show - Main Navigation"
"Hide - Main Navigation"

... is always visible on the mobile menu bar.

dcrocks’s picture

emma.maria’s picture

Oh! I was completely unaware of this issue. I'm normally flagged for Bartik changes.

Thank you @dcrocks!!!

emma.maria’s picture

Assigned: emma.maria » Unassigned
Status: Needs review » Needs work
Issue tags: +CSS, +frontend

Code review of #2.

Instead of repeating the styles within two separate media queries (tablet width and then the desktop width), we should just add a tablet and up media query for this code.

We are only targeting the mobile toggle, which has no further state changes above 461px.

For eg.

@media all and (min-width: 461px) {
  body:not(:target) .region-primary-menu .menu-toggle-target-show:target ~ .menu-toggle--hide {
    display: none;
  }
}
meichr’s picture

Assigned: Unassigned » meichr
meichr’s picture

Assigned: meichr » Unassigned
Status: Needs work » Needs review
FileSize
700 bytes

Thank you for reviewing my patch. That makes sense to reduce lines of code.
The new media query needs to be added at the end of primary-menu.css to overwrite the CSS in the display width smaller than 461px in bigger display sizes like tablet and desktop display. The new patch is attached here and applies at least to today's git code base in 8.1.x. I've named the patch according to How to create a Drupal patch using git., I hope that is good.
All the above screen shots still apply and I've not added a desktop screenshot to keep the length of this issue simple, but I tested it similarly by setting a desktop width like 1280 using the Firefox tools.

emma.maria’s picture

Status: Needs review » Needs work

Hi @meichr thanks for the patch.

Ignoring how the rest of the file is currently structured (it is in the process of being refactored here - #2502045: Replace the "Primary menu" component with a reusable component in Bartik.) please can you make the following amendments to the patch to help it pass Drupal CSS coding standards.

Can the comment be placed completely outside of the ruleset and be placed in a Doxygen comment style. The media query is helping to set a state onto the component (ie. the component is hidden when the screen are these dimensions) and we want the comment to explain the whole scenario of the code we are adding here.

See the coding standards for how to comment for a complete ruleset here:
https://www.drupal.org/node/1887862#multi-line-comments

Also to keep things succinct, the comment copy can be shortened to something like:
"Ensures that the open mobile menu hides when the screen dimensions become bigger than 461px."

If you feel it needs more to explain why we adding this style you can also add...
"- see *insert URL to this issue*"
at the end of the comment.

Thanks!

emma.maria’s picture

Issue tags: +DrupalBCDays
meichr’s picture

Assigned: Unassigned » meichr
meichr’s picture

Assigned: meichr » Unassigned
Status: Needs work » Needs review
FileSize
666 bytes

Hi @emma.maria. Thanks for the time you take to help me getting more experienced and providing the link to the coding standards.
I understand from your remark, that because the new media query has only been created for one ruleset hiding the button that I move the comment explaining the hiding ruleset before the media query. Would there ever be another ruleset to be added to this same media query the existing comment then would have to be placed inside the media query before the hiding ruleset. I didn't find any specifics about such a case in the coding standards.

I've added the revised patch.

Regarding #2502045: Replace the "Primary menu" component with a reusable component in Bartik.: should this patch be worked into the current patch over there? Or do you plan to commit this patch individually to 8.1.x?

Thanks.

emma.maria’s picture

Issue tags: +Needs screenshots

Hi @meichr

We want to try and move away from everything being grouped by media queries. You lose the ease of seeing how a component is styled at different states if it's scattered throughout a file. Also not every component needs styles for every media query and it definitely becomes harder to maintain if you need to jump around the file looking for all the styles for one component.

We ideally want to have all of the code for a component grouped together in a file with each media query it uses.

For example.

.open-menu {
  *styles*
}
@media all and (min-width: 300px) {
  .open-menu {
      *styles*
  }
}
@media all and (min-width: 600px) {
  .open-menu {
      *styles*
  }
}

So for the question....

Would there ever be another ruleset to be added to this same media query the existing comment then would have to be placed inside the media query before the hiding ruleset.

If another component needs the same media query, we would add another media query declaration around that other component. Yes there will be duplicate media queries all over the file, but the organisation of the styles should be component first and not media query first.

Also answering...

Regarding #2502045: Replace the "Primary menu" component with a reusable component in Bartik.: should this patch be worked into the current patch over there? Or do you plan to commit this patch individually to 8.1.x?

Keep this work only in this issue. This bug issue will be committed before that bigger task and therefore this work will automatically end up in that issue from it being applied to the core codebase.

Thanks for the patch @meichr!

The last step is for someone apart from @meichr to add some review screenshots (showing the menu is now hidden at tablet and desktop widths) and set it to RTBC. I will do this later today if no one else does.

Pnoia’s picture

I'll do the screenshots

Pnoia’s picture

Issue summary: View changes
FileSize
39.55 KB
43.03 KB
33.88 KB
41.97 KB

I followed steps in issue summary and things are resolved with patch from #22.

chrome before
chrome after
firefox before
firefox after

Pnoia’s picture

Status: Needs review » Reviewed & tested by the community
Pnoia’s picture

meichr’s picture

Issue tags: -Needs screenshots

Thanks, @Pnoi !

emma.maria’s picture

Issue summary: View changes

Thanks @Pnoi for the review!

Suggested commit message:

git commit -m 'Issue #2661128 by meichr, kannan@kiluvai.com, Pnoi, emma.maria: Bartik - Responsive menu-toggle shows up in show mode after switching from mobile to pad or desktop display'

xjm’s picture

Issue tags: +rc target triage

Since this involves a visual bugfix to Bartik, tagging for RC target triage.

star-szr’s picture

Version: 8.1.x-dev » 8.2.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: -rc target triage

Discussed with @xjm and we agreed that this is not a high impact bugfix (kind of an edge case and not really that broken/disruptive to users IMO even when the bug does happen), so removing from RC triage and moving to 8.2.x. https://www.drupal.org/core/d8-allowed-changes#rc

This took me a while to decode the issue summary and reproduce so I've updated it slightly, mostly tried to put a brief numbered list of steps to reproduce that I think sum up the bug here.

+++ b/core/themes/bartik/css/components/primary-menu.css
@@ -200,3 +200,13 @@ body:not(:target) .region-primary-menu .menu-toggle-target-show:target ~ .menu .
+ * Ensures that the open mobile menu hides when the screen dimensions become
+ * bigger than 461px.
...
+@media all and (min-width: 461px) {

Sorry to have to push back on this but "bigger than 461px" doesn't seem accurate (it's actually 461px or wider, not 462 or wider). I think we should say something like "wider than 460px" or "461px or wider".

meichr’s picture

Thanks, @Cottser! Have updated the patch with the corrected remark.

emma.maria’s picture

emma.maria’s picture

Status: Needs review » Reviewed & tested by the community

The patch matches what was asked by @Cottser. I'm marking this RTBC again.

star-szr’s picture

Status: Reviewed & tested by the community » Fixed

Committed ae233ac and pushed to 8.2.x. Thanks!

  • Cottser committed ae233ac on 8.2.x
    Issue #2661128 by meichr, kannan@kiluvai.com, Pnoi, emma.maria, dcrocks...
emma.maria’s picture

Well done all!

Also I forgot to say a big thank you to @Cottser for the thorough review at #31!

Status: Fixed » Closed (fixed)

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