BigW Consortium Gitlab
Refactor sidebar logic for more predictable behavior ## What does this MR do? Fixes a few bugs with the sidebar and "pin" functionality: 1. Pinned state would get reset when loading a page with a viewport smaller than 1024px (#19183) 2. Toggle buttons could occasionally end up in an invalid state in which the toggle is hidden from view at the same time the sidebar is collapsed. ![2016-09-03-09.39.07](/uploads/75d9a836ab58aae9f89f38cc29e90bbd/2016-09-03-09.39.07.gif) 3. Clicking outside the sidebar to trigger 'collapse' when below the 1024px breakpoint would work only if not pinned, even though pin status should only effect the sidebar above the 1024px breakpoint. 4. Code confusing with no single source of truth for the state of the sidebar. Sometimes pinned state is inferred from the cookie, sometimes from the DOM. Code to handle these functions was confusingly split across both `sidebar.js` and `application.js` for no apparent reason. I've created a singleton ES6 class to handle the sidebar DOM manipulations, using the properties `isExpanded` and `isPinned` as the canonical state and providing a `renderState` method to sync the DOM with this state whenever it needs updating. This avoids the possibility of invalid states caused by reliance on jQuery `toggleClass()` methods and makes the code much more readable/maintainable. ## Are there points in the code the reviewer needs to double check? It is a substantial rewrite, so I could use another set of eyes to make sure nothing was left behind from the original implementation. ## Why was this MR needed? I initially intended to just fix #19183 by modifying the code in place, but it proved to be a difficult mess and rather than add to the technical debt it made sense to write a more readable implementation of the sidebar functionality. ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [ ] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Closes #19183 See merge request !6169
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
application_helper_spec.rb | Loading commit data... | |
auth_helper_spec.rb | Loading commit data... | |
blob_helper_spec.rb | Loading commit data... | |
broadcast_messages_helper_spec.rb | Loading commit data... | |
ci_status_helper_spec.rb | Loading commit data... | |
commits_helper_spec.rb | Loading commit data... | |
diff_helper_spec.rb | Loading commit data... | |
emails_helper_spec.rb | Loading commit data... | |
events_helper_spec.rb | Loading commit data... | |
form_helper_spec.rb | Loading commit data... | |
gitlab_markdown_helper_spec.rb | Loading commit data... | |
gitlab_routing_helper_spec.rb | Loading commit data... | |
graph_helper_spec.rb | Loading commit data... | |
groups_helper_spec.rb | Loading commit data... | |
icons_helper_spec.rb | Loading commit data... | |
import_helper_spec.rb | Loading commit data... | |
issuables_helper_spec.rb | Loading commit data... | |
issues_helper_spec.rb | Loading commit data... | |
labels_helper_spec.rb | Loading commit data... | |
members_helper_spec.rb | Loading commit data... | |
merge_requests_helper_spec.rb | Loading commit data... | |
notes_helper_spec.rb | Loading commit data... | |
notifications_helper_spec.rb | Loading commit data... | |
page_layout_helper_spec.rb | Loading commit data... | |
preferences_helper_spec.rb | Loading commit data... | |
projects_helper_spec.rb | Loading commit data... | |
runners_helper_spec.rb | Loading commit data... | |
search_helper_spec.rb | Loading commit data... | |
submodule_helper_spec.rb | Loading commit data... | |
tab_helper_spec.rb | Loading commit data... | |
time_helper_spec.rb | Loading commit data... | |
tree_helper_spec.rb | Loading commit data... | |
visibility_level_helper_spec.rb | Loading commit data... |