summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2018-02-12 19:30:03 -0600
committerEric Eastwood <contact@ericeastwood.com>2018-02-13 10:36:47 -0600
commit37d3d07b9ffd59f6e214c13247c4b95be9816c78 (patch)
treea2b211c49ed73d602f920c324b54954e46e8959f
parentee8e5a596c3d4e18a227185965b52baf6f66c5db (diff)
downloadgitlab-ce-37d3d07b9ffd59f6e214c13247c4b95be9816c78.tar.gz
Fix settings panel not expanding when fragment hash linked
See https://gitlab.com/gitlab-org/gitlab-ce/issues/43198
-rw-r--r--app/assets/javascripts/settings_panels.js2
-rw-r--r--changelogs/unreleased/43198-fix-settings-panel-expanding-when-fragment-hash-linked.yml5
-rw-r--r--spec/javascripts/settings_panels_spec.js29
3 files changed, 35 insertions, 1 deletions
diff --git a/app/assets/javascripts/settings_panels.js b/app/assets/javascripts/settings_panels.js
index d34a21b37e1..d0e4f533d8a 100644
--- a/app/assets/javascripts/settings_panels.js
+++ b/app/assets/javascripts/settings_panels.js
@@ -42,7 +42,7 @@ export default function initSettingsPanels() {
if (location.hash) {
const $target = $(location.hash);
- if ($target.length && $target.hasClass('.settings')) {
+ if ($target.length && $target.hasClass('settings')) {
expandSection($target);
}
}
diff --git a/changelogs/unreleased/43198-fix-settings-panel-expanding-when-fragment-hash-linked.yml b/changelogs/unreleased/43198-fix-settings-panel-expanding-when-fragment-hash-linked.yml
new file mode 100644
index 00000000000..49ba48a0fef
--- /dev/null
+++ b/changelogs/unreleased/43198-fix-settings-panel-expanding-when-fragment-hash-linked.yml
@@ -0,0 +1,5 @@
+---
+title: Fix settings panels not expanding when fragment hash linked
+merge_request: 17074
+author:
+type: fixed
diff --git a/spec/javascripts/settings_panels_spec.js b/spec/javascripts/settings_panels_spec.js
new file mode 100644
index 00000000000..d433f8c3e07
--- /dev/null
+++ b/spec/javascripts/settings_panels_spec.js
@@ -0,0 +1,29 @@
+import initSettingsPanels from '~/settings_panels';
+
+describe('Settings Panels', () => {
+ preloadFixtures('projects/ci_cd_settings.html.raw');
+
+ beforeEach(() => {
+ loadFixtures('projects/ci_cd_settings.html.raw');
+ });
+
+ describe('initSettingsPane', () => {
+ afterEach(() => {
+ location.hash = '';
+ });
+
+ it('should expand linked hash fragment panel', () => {
+ location.hash = '#js-general-pipeline-settings';
+
+ const pipelineSettingsPanel = document.querySelector('#js-general-pipeline-settings');
+ // Our test environment automatically expands everything so we need to clear that out first
+ pipelineSettingsPanel.classList.remove('expanded');
+
+ expect(pipelineSettingsPanel.classList.contains('expanded')).toBe(false);
+
+ initSettingsPanels();
+
+ expect(pipelineSettingsPanel.classList.contains('expanded')).toBe(true);
+ });
+ });
+});