Skip to content

Commit 6b70b77

Browse files
committed
Merge branch 'add-gl-link-to-markdown-header' into 'master'
Change markdown header tab anchor links to buttons See merge request gitlab-org/gitlab-ce!21988
2 parents cdfc237 + 1af6ddf commit 6b70b77

File tree

13 files changed

+56
-38
lines changed

13 files changed

+56
-38
lines changed

app/assets/javascripts/vue_shared/components/markdown/header.vue

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<script>
22
import $ from 'jquery';
3-
import tooltip from '../../directives/tooltip';
4-
import toolbarButton from './toolbar_button.vue';
5-
import icon from '../icon.vue';
3+
import Tooltip from '../../directives/tooltip';
4+
import ToolbarButton from './toolbar_button.vue';
5+
import Icon from '../icon.vue';
66
77
export default {
88
directives: {
9-
tooltip,
9+
Tooltip,
1010
},
1111
components: {
12-
toolbarButton,
13-
icon,
12+
ToolbarButton,
13+
Icon,
1414
},
1515
props: {
1616
previewMarkdown: {
@@ -68,27 +68,27 @@ export default {
6868
:class="{ active: !previewMarkdown }"
6969
class="md-header-tab"
7070
>
71-
<a
71+
<button
7272
class="js-write-link"
73-
href="#md-write-holder"
7473
tabindex="-1"
75-
@click.prevent="writeMarkdownTab($event)"
74+
type="button"
75+
@click="writeMarkdownTab($event)"
7676
>
7777
Write
78-
</a>
78+
</button>
7979
</li>
8080
<li
8181
:class="{ active: previewMarkdown }"
8282
class="md-header-tab"
8383
>
84-
<a
84+
<button
8585
class="js-preview-link js-md-preview-button"
86-
href="#md-preview-holder"
8786
tabindex="-1"
88-
@click.prevent="previewMarkdownTab($event)"
87+
type="button"
88+
@click="previewMarkdownTab($event)"
8989
>
9090
Preview
91-
</a>
91+
</button>
9292
</li>
9393
<li
9494
:class="{ active: !previewMarkdown }"

app/assets/stylesheets/framework/gitlab_theme.scss

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161

162162
.nav-links li {
163163
&.active a,
164+
&.md-header-tab.active button,
164165
a.active {
165166
border-bottom: 2px solid $active-tab-border;
166167

app/assets/stylesheets/framework/markdown_area.scss

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
.md-header-tab {
7373
@include media-breakpoint-down(xs) {
7474
flex: 1;
75+
flex-direction: column;
7576
width: 100%;
7677
border-bottom: 1px solid $border-color;
7778
text-align: center;

app/assets/stylesheets/framework/secondary_navigation_elements.scss

+13-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
height: auto;
99
border-bottom: 1px solid $border-color;
1010

11-
li {
11+
li:not(.md-header-toolbar) {
1212
display: flex;
1313

14-
a {
14+
a,
15+
button {
1516
padding: $gl-btn-padding;
1617
padding-bottom: 11px;
1718
font-size: 14px;
1819
line-height: 28px;
1920
color: $gl-text-color-secondary;
21+
border: 0;
2022
border-bottom: 2px solid transparent;
2123
white-space: nowrap;
2224

@@ -33,7 +35,12 @@
3335
}
3436
}
3537

38+
button {
39+
padding-top: 0;
40+
}
41+
3642
&.active a,
43+
&.active button,
3744
a.active {
3845
color: $black;
3946
font-weight: $gl-font-weight-bold;
@@ -42,6 +49,10 @@
4249
color: $black;
4350
}
4451
}
52+
53+
&.md-header-tab button {
54+
line-height: 19px;
55+
}
4556
}
4657
}
4758

app/views/projects/_md_preview.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
.md-header
1212
%ul.nav.nav-tabs.nav-links.clearfix
1313
%li.md-header-tab.active
14-
%a.js-md-write-button{ href: "#md-write-holder", tabindex: -1 }
14+
%button.js-md-write-button{ tabindex: -1 }
1515
Write
1616
%li.md-header-tab
17-
%a.js-md-preview-button{ href: "#md-preview-holder", tabindex: -1 }
17+
%button.js-md-preview-button{ tabindex: -1 }
1818
Preview
1919

2020
%li.md-header-toolbar.active
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Change markdown header tab anchor links to buttons
3+
merge_request: 21988
4+
author: George Tsiolis
5+
type: other

spec/features/groups/milestone_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323

2424
description.native.send_keys('')
2525

26-
click_link('Preview')
26+
click_button('Preview')
2727

2828
preview = find('.js-md-preview')
2929

3030
expect(preview).to have_content('Nothing to preview.')
3131

32-
click_link('Write')
32+
click_button('Write')
3333

3434
description.native.send_keys(':+1: Nice')
3535

36-
click_link('Preview')
36+
click_button('Preview')
3737

3838
expect(preview).to have_css('gl-emoji')
3939
expect(find('#milestone_description', visible: false)).not_to be_visible

spec/features/issues/user_creates_issue_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
textarea = first(".gfm-form textarea")
4848

4949
page.within(form) do
50-
click_link("Preview")
50+
click_button("Preview")
5151

5252
preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked.
5353

5454
expect(preview).to have_content("Nothing to preview.")
5555

56-
click_link("Write")
56+
click_button("Write")
5757
fill_in("Description", with: "Bug fixed :smile:")
58-
click_link("Preview")
58+
click_button("Preview")
5959

6060
expect(preview).to have_css("gl-emoji")
6161
expect(textarea).not_to be_visible

spec/features/issues/user_edits_issue_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
page.within(form) do
1919
fill_in("Description", with: "Bug fixed :smile:")
20-
click_link("Preview")
20+
click_button("Preview")
2121
end
2222

23-
expect(form).to have_link("Write")
23+
expect(form).to have_button("Write")
2424
end
2525
end

spec/features/merge_request/user_views_open_merge_request_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
find('.gfm-form').fill_in(:merge_request_description, with: '')
4242

4343
page.within('.gfm-form') do
44-
click_link('Preview')
44+
click_button('Preview')
4545

4646
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
4747
end
@@ -51,12 +51,12 @@
5151
find('.gfm-form').fill_in(:merge_request_description, with: ':+1: Nice')
5252

5353
page.within('.gfm-form') do
54-
click_link('Preview')
54+
click_button('Preview')
5555

5656
expect(find('.js-md-preview')).to have_css('gl-emoji')
5757
end
5858

59-
expect(find('.gfm-form')).to have_css('.js-md-preview').and have_link('Write')
59+
expect(find('.gfm-form')).to have_css('.js-md-preview').and have_button('Write')
6060
expect(find('#merge_request_description', visible: false)).not_to be_visible
6161
end
6262
end

spec/features/projects/commit/comments/user_adds_comment_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@
2828
fill_in("note[note]", with: "#{comment_text} #{emoji}")
2929

3030
# Check on `Preview` tab
31-
click_link("Preview")
31+
click_button("Preview")
3232

3333
expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji")
3434
expect(page).not_to have_css(".js-note-text")
3535

3636
# Check on the `Write` tab
37-
click_link("Write")
37+
click_button("Write")
3838

3939
expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji}")
4040

4141
# Submit comment from the `Preview` tab to get rid of a separate `it` block
4242
# which would specially tests if everything gets cleared from the note form.
43-
click_link("Preview")
43+
click_button("Preview")
4444
click_button("Comment")
4545
end
4646

@@ -88,13 +88,13 @@
8888

8989
# Test Preview feature for both forms.
9090
page.within("form[data-line-code='#{sample_commit.line_code}']") do
91-
click_link("Preview")
91+
click_button("Preview")
9292
end
9393

9494
page.within("form[data-line-code='#{sample_commit.del_line_code}']") do
9595
fill_in("note[note]", with: another_comment_text)
9696

97-
click_link("Preview")
97+
click_button("Preview")
9898
end
9999

100100
expect(page).to have_css(".js-md-preview", visible: true, count: 2)

spec/features/projects/commit/user_comments_on_commit_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
fill_in("note[note]", with: "#{comment_text} #{emoji_code}")
2626

2727
# Check on `Preview` tab
28-
click_link("Preview")
28+
click_button("Preview")
2929

3030
expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji")
3131
expect(page).not_to have_css(".js-note-text")
3232

3333
# Check on `Write` tab
34-
click_link("Write")
34+
click_button("Write")
3535

3636
expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji_code}")
3737

3838
# Submit comment from the `Preview` tab to get rid of a separate `it` block
3939
# which would specially tests if everything gets cleared from the note form.
40-
click_link("Preview")
40+
click_button("Preview")
4141
click_button("Comment")
4242
end
4343

spec/javascripts/vue_shared/components/markdown/header_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Markdown field header component', () => {
7676
});
7777

7878
it('blurs preview link after click', done => {
79-
const link = vm.$el.querySelector('li:nth-child(2) a');
79+
const link = vm.$el.querySelector('li:nth-child(2) button');
8080
spyOn(HTMLElement.prototype, 'blur');
8181

8282
link.click();

0 commit comments

Comments
 (0)