Fix settings panel not expanding when fragment hash linked
See https://gitlab.com/gitlab-org/gitlab-ce/issues/43198
This commit is contained in:
parent
ee8e5a596c
commit
37d3d07b9f
3 changed files with 35 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix settings panels not expanding when fragment hash linked
|
||||
merge_request: 17074
|
||||
author:
|
||||
type: fixed
|
29
spec/javascripts/settings_panels_spec.js
Normal file
29
spec/javascripts/settings_panels_spec.js
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue