Commit 49780c02 authored by Marcel van Remmerden's avatar Marcel van Remmerden Committed by Miguel Rincon

Fix segmented control in file header for markdown files

parent 7516adb5
...@@ -132,16 +132,16 @@ export default class BlobViewer { ...@@ -132,16 +132,16 @@ export default class BlobViewer {
const newViewer = this.$fileHolder[0].querySelector(`.blob-viewer[data-type='${name}']`); const newViewer = this.$fileHolder[0].querySelector(`.blob-viewer[data-type='${name}']`);
if (this.activeViewer === newViewer) return; if (this.activeViewer === newViewer) return;
const oldButton = document.querySelector('.js-blob-viewer-switch-btn.active'); const oldButton = document.querySelector('.js-blob-viewer-switch-btn.selected');
const newButton = document.querySelector(`.js-blob-viewer-switch-btn[data-viewer='${name}']`); const newButton = document.querySelector(`.js-blob-viewer-switch-btn[data-viewer='${name}']`);
const oldViewer = this.$fileHolder[0].querySelector(`.blob-viewer:not([data-type='${name}'])`); const oldViewer = this.$fileHolder[0].querySelector(`.blob-viewer:not([data-type='${name}'])`);
if (oldButton) { if (oldButton) {
oldButton.classList.remove('active'); oldButton.classList.remove('selected');
} }
if (newButton) { if (newButton) {
newButton.classList.add('active'); newButton.classList.add('selected');
newButton.blur(); newButton.blur();
} }
......
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
= sprite_icon(simple_viewer.switcher_icon) = sprite_icon(simple_viewer.switcher_icon)
- rich_label = "Display #{rich_viewer.switcher_title}" - rich_label = "Display #{rich_viewer.switcher_title}"
%button.btn.gl-button.btn-default.btn-sm.js-blob-viewer-switch-btn.has-tooltip{ 'aria-label' => rich_label, title: rich_label, data: { viewer: 'rich', container: 'body' } }> %button.btn.gl-button.btn-default.btn-sm.js-blob-viewer-switch-btn.gl-mr-3.has-tooltip{ 'aria-label' => rich_label, title: rich_label, data: { viewer: 'rich', container: 'body' } }>
= sprite_icon(rich_viewer.switcher_icon) = sprite_icon(rich_viewer.switcher_icon)
---
title: Fix margin and selected state in file header
merge_request: 49059
author:
type: fixed
...@@ -154,7 +154,7 @@ describe('Blob viewer', () => { ...@@ -154,7 +154,7 @@ describe('Blob viewer', () => {
blob.switchToViewer('simple'); blob.switchToViewer('simple');
expect(simpleBtn.classList.contains('active')).toBeTruthy(); expect(simpleBtn.classList.contains('selected')).toBeTruthy();
expect(simpleBtn.blur).toHaveBeenCalled(); expect(simpleBtn.blur).toHaveBeenCalled();
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment