diff options
author | Jose Ivan Vargas Lopez <jvargas@gitlab.com> | 2016-11-14 12:56:52 -0600 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-01-25 11:53:43 -0600 |
commit | ae65272bbf6f66162730f373bfa0236c67276c11 (patch) | |
tree | c4c82a377ae9c488e4dab39ad64b66c8f166a116 | |
parent | b55c1bc4b5fb8d259ba9f264eff607f81012fa39 (diff) | |
download | gitlab-ce-ae65272bbf6f66162730f373bfa0236c67276c11.tar.gz |
Fixed Issuable sidebar so it remains closed on mobile/smaller screen devices
Added test to replicate the bug, also added a couple of helpers that can be reused
on the testing suite to resize the browser window, these helpers are located on the
spec/support/mobile_helpers.rb
-rw-r--r-- | app/assets/javascripts/application.js | 17 | ||||
-rw-r--r-- | changelogs/unreleased/issuable-sidebar-bug.yml | 4 | ||||
-rw-r--r-- | spec/features/issues/issue_sidebar_spec.rb | 26 | ||||
-rw-r--r-- | spec/support/mobile_helpers.rb | 13 |
4 files changed, 50 insertions, 10 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f0615481ed2..1333bea5644 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -84,7 +84,6 @@ var $sidebarGutterToggle = $('.js-sidebar-toggle'); var $flash = $('.flash-container'); var bootstrapBreakpoint = bp.getBreakpointSize(); - var checkInitialSidebarSize; var fitSidebarForSize; // Set the default path for all cookies to GitLab's root directory @@ -246,19 +245,19 @@ return $document.trigger('breakpoint:change', [bootstrapBreakpoint]); } }; - checkInitialSidebarSize = function () { - bootstrapBreakpoint = bp.getBreakpointSize(); - if (bootstrapBreakpoint === 'xs' || 'sm') { - return $document.trigger('breakpoint:change', [bootstrapBreakpoint]); - } - }; $window.off('resize.app').on('resize.app', function () { return fitSidebarForSize(); }); + window.addEventListener('beforeunload', function() { + // collapsed_gutter cookie hides the sidebar + var bpBreakpoint = bp.getBreakpointSize(); + if (bpBreakpoint === 'xs' || bpBreakpoint === 'sm') { + Cookies.set('collapsed_gutter', true); + } + }); + gl.awardsHandler = new AwardsHandler(); - checkInitialSidebarSize(); new Aside(); - // bind sidebar events new gl.Sidebar(); }); diff --git a/changelogs/unreleased/issuable-sidebar-bug.yml b/changelogs/unreleased/issuable-sidebar-bug.yml new file mode 100644 index 00000000000..4086292eb89 --- /dev/null +++ b/changelogs/unreleased/issuable-sidebar-bug.yml @@ -0,0 +1,4 @@ +--- +title: Fixed Issuable sidebar not closing on smaller/mobile sized screens +merge_request: +author: diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index bc068b5e7e0..64f7835eecd 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' feature 'Issue Sidebar', feature: true do - include WaitForAjax + include WaitForAjax, MobileHelpers let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } @@ -59,6 +59,30 @@ feature 'Issue Sidebar', feature: true do end end + context 'sidebar', js: true do + it 'changes size when the screen size is smaller' do + sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed' + # Resize the window + resize_screen_sm + # Make sure the sidebar is collapsed + expect(page).to have_css(sidebar_selector) + # Once is collapsed let's open the sidebard and reload + page.within(sidebar_selector) do + find('.js-sidebar-toggle').click + # we wait a bit so the sidebar finishes it's animation + sleep 1 + end + refresh + expect(page).to have_css(sidebar_selector) + # Restore the window size as it was including the sidebar + restore_window_size + page.within(sidebar_selector) do + find('.js-sidebar-toggle').click + sleep 1 + end + end + end + context 'creating a new label', js: true do it 'shows option to crate a new label is present' do page.within('.block.labels') do diff --git a/spec/support/mobile_helpers.rb b/spec/support/mobile_helpers.rb new file mode 100644 index 00000000000..20d5849bcab --- /dev/null +++ b/spec/support/mobile_helpers.rb @@ -0,0 +1,13 @@ +module MobileHelpers + def resize_screen_sm + resize_window(900, 768) + end + + def restore_window_size + resize_window(1366, 768) + end + + def resize_window(width, height) + page.driver.resize_window width, height + end +end |